Wikisym 2012 Demo: Difference between revisions
Jump to navigation
Jump to search
(Created page with "== Polygons on Google Maps == This example plots municipalities of Finland on Google Maps using data from National Land Survey of Finland. <rcode name="polygons_on_google_maps...") |
|||
Line 7: | Line 7: | ||
library(rgdal) | library(rgdal) | ||
# Get the shape data of Finnish municipalities using soRvi library | |||
data(MML) | data(MML) | ||
shp <- MML[["1_milj_Shape_etrs_shape"]][["kunta1_p"]] | shp <- MML[["1_milj_Shape_etrs_shape"]][["kunta1_p"]] | ||
# Set the projection | |||
epsg4326String <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs") | epsg4326String <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs") | ||
proj4string(shp)<-("+init=epsg:3047") | proj4string(shp)<-("+init=epsg:3047") | ||
shp2<-spTransform(shp,epsg4326String) | shp2<-spTransform(shp,epsg4326String) | ||
out<-sapply(slot(shp2,"polygons"),function(x){kmlPolygon(x,name=" | # 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( | data<-paste( | ||
paste(kmlPolygon(kmlname="This will be layer name", kmldescription="<i>More info about layer here</i>")$header, collapse="\n"), | paste(kmlPolygon(kmlname="This will be layer name", kmldescription="<i>More info about layer here</i>")$header, collapse="\n"), | ||
Line 24: | Line 25: | ||
sep='' | sep='' | ||
) | ) | ||
# Show the KML data on Google Maps | |||
google.show_kml_data_on_maps(data) | |||
</rcode> | </rcode> |
Revision as of 10:35, 21 August 2012
Polygons on Google Maps
This example plots municipalities of Finland on Google Maps using data from National Land Survey of Finland.