【发布时间】:2020-11-09 23:57:54
【问题描述】:
library(ggmap) # -- for geocoding, obtaining city locations
readRDS("gadm36_IND_2_sp.rds")
ind2 = gadm
最后的输出如下:
插槽“bbox”: 最小最大 x 68.186249 97.41516 是的 6.754256 35.50133
插槽“proj4string”: CRS 论点: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 eval 中的错误(expr、envir、enclos):找不到对象“gadm” 追溯:
接下来的代码是:
# plotting districts of a State, in this case West Bengal
wb2 = (ind2[ind2$NAME_1=="West Bengal",])
nam = c("Purulia","Bankura","Midnapur")
pos = geocode(nam)
tlat = pos$lat+0.05 # -- the city name will be above the marker
cities = data.frame(nam, pos$lon,pos$lat,tlat)
names(cities)[2] = "lon"
names(cities)[3] = "lat"
text1 = list("panel.text", cities$lon, cities$tlat, cities$nam,col="red", cex = 0.75)
mark1 = list("panel.points", cities$lon, cities$lat, col="blue")
text2 = list("panel.text",87.0,26.0,"GADM map", col = "dark green", cex = 1.2)
spplot(wb2, "NAME_1",
sp.layout=list(text1,mark1, text2),
main="West Bengal Districts",
colorkey=FALSE, scales=list(draw=TRUE))
上述代码的输出是: eval 中的错误(expr、envir、enclos):找不到对象“ind2” 追溯:
如何在地图中绘制位置?
【问题讨论】: