[R-sig-Geo] kml and points

Roger Bivand Roger.Bivand at nhh.no
Sat Aug 7 11:15:06 CEST 2010


On Sat, 7 Aug 2010, Patrick Giraudoux wrote:

> Dear All,
>
> I have just discovered  the fantastic possibilities given with kmlPolygon, 
> klmLine and kmlOverlay (package maptools) to project spatial objects into 
> google earth.
>
> Does anyone knows if a function equivalent has been written to create a kml 
> file of "points" ? If not, is there a technical reason not to have done it or 
> a workaround which would make such function unecessary ?

Would the KML driver for writeOGR() in rgdal be enough? The variables (or 
a subset of the variables) in the SpatialPointsDataFrame are displayed in 
the bubble on clicking. You do not, I think, get a choice of point symbol.

td <- tempdir()
data(meuse)
coordinates(meuse) <- c("x", "y")
proj4string(meuse) <- CRS("+init=epsg:28992")
meuse_ll <- spTransform(meuse, CRS("+proj=longlat +datum=WGS84"))
writeOGR(meuse_ll, paste(td, "meuse.kml", sep="/"), "zinc", "KML")
file.show(paste(td, "meuse.kml", sep="/"))

See http://www.gdal.org/ogr/drv_kml.html, and note the section on encoding 
if on Windows.

Roger

>
> Patrick
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list