在使用R语言软件时绘制成都市地图为什么不通过啊
library(rgdal)
library(mapdata)
library(maps)
library(maptools)
library(ggplot2)
map.shp<-readShapePoly("BOUNT_poly.shp")
tmp<-map.shp$NAME99
grep("成都",tmp,value=TRUE)
grep("成都",tmp)
map.shp$ADCODE99[grep("成都",tmp)]
Chengdu<-map.shp[substr(as.character(map.shp$ADCODE99),1,4)=="5101",]
mpsh<-fortify(Chengdu)
qplot(long,lat,data=mpsh)+geom_map(aes(map_id=id,),color="black",fill=NA,map=mpsh)+coord_map()
Warning: readShapePoly is deprecated; use rgdal::readOGR or sf::st_read
character(0)
integer(0)
NULL
Regions defined for each Polygons
Error in geom_map()
:
! map
must have the columns x
, y
, and id
Backtrace:
你可以查看以下变量 mpsh 有没有问题,是不是你需要的数据