psl*_*ice 5 mapping google-maps r shapefile
我有一些我想在Google地图图块上绘制的shapefile.最有效的方法是什么?一条路径可能是使用pkg RgoogleMaps,但是,我仍然不清楚如何执行此操作.我假设使用PlotonStaticMap重新格式化shapefile数据
从开发人员,它似乎很好地工作.
shpFile <- system.file("shapes/sids.shp", package="maptools");
shp<-importShapefile(shpFile,projection="LL");
bb <- qbbox(lat = shp[,"Y"], lon = shp[,"X"]);
MyMap <- GetMap.bbox(bb$lonR, bb$latR, destfile = "SIDS.jpg");
#compute regularized SID rate
sid <- 100*attr(shp, "PolyData")$SID74/(attr(shp, "PolyData")$BIR74+500)
b <- as.integer(cut(sid, quantile(sid, seq(0,1,length=8)) ));
b[is.na(b)] <- 1;
opal <- col2rgb(grey.colors(7), alpha=TRUE)/255; opal["alpha",] <- 0.2;
shp[,"col"] <- rgb(0.1,0.1,0.1,0.2);
for (i in 1:length(b)) shp[shp[,"PID"] == i,"col"] <- rgb(opal[1,b[i]],opal[2,b[i]],opal[3,b[i]],opal[4,b[i]]);
PlotPolysOnStaticMap(MyMap, shp, lwd=.5, col = shp[,"col"], add = F);
Run Code Online (Sandbox Code Playgroud)