June 2016
Beginner to intermediate
1783 pages
71h 22m
English
In this recipe, we will learn how to read and write geographic data in Google's Keyhole Markup Language (KML) format, which can be used to visualize geographic data with Google Earth and Google Maps.
We will use the rgdal package in this recipe. So, let's make sure it's installed and load it:
install.packages("rgdal")
library(rgdal)We will use data from the cities shapefile that's installed as part of the rgdal package. First, we will write a KML file and then read it:
cities <- readOGR(system.file("vectors",
package = "rgdal")[1],"cities")
writeOGR(cities, "cities.kml", "cities", driver="KML")
df <- readOGR("cities.kml", "cities")In the preceding example, we first used the ...
Read now
Unlock full access