Wikisym 2012 Demo
Polygons on Google Maps
This example plots municipalities of Finland on Google Maps using data from National Land Survey of Finland.
This example plots municipalities of Finland on Google Maps using data from National Land Survey of Finland.
library(OpasnetBaseUtils) library(sorvi) library(rgdal) # Get the shape data of Finnish municipalities using soRvi library data(MML) shp <- MML[["1_milj_Shape_etrs_shape"]][["kunta1_p"]] # Set the projection epsg4326String <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs") proj4string(shp)<-("+init=epsg:3047") shp2<-spTransform(shp,epsg4326String) # Create the KML data using the shape out<-sapply(slot(shp2,"polygons"),function(x){kmlPolygon(x,name="name",col='#df0000aa',lwd=1,border='black',description="desc") }) data<-paste( paste(kmlPolygon(kmlname="This will be layer name", kmldescription="<i>More info about layer here</i>")$header, collapse="\n"), paste(unlist(out["style",]), collapse="\n"), paste(unlist(out["content",]), collapse="\n"), paste(kmlPolygon()$footer, collapse="\n"), sep='' ) # Show the KML data on Google Maps google.show_kml_data_on_maps(data) |