【发布时间】:2011-04-20 14:33:34
【问题描述】:
我尝试使用merge 和 2 位 ISO 代码作为 ID 将经济数据添加到 shapefile。代码看起来有点像这样:
library(maptools)
library(foreign)
library(sp)
library(lattice)
library(shapefiles)
world.shp<-readShapePoly("world_shapefile.shp")
world.shp@data<-merge(world.shp@data, data.frame(country=iso.code.vector, net=country.data.vector), by.x="ISO2", by.y="country", all.x=TRUE, sort=FALSE)
不幸的是,即使我输入了sort 参数,这也会破坏 .shp 文件的顺序。之后的图显示数据与应有的多边形不匹配。我做错了什么?
我从thematicmapping.org得到了世界地图数据
感谢您的帮助
【问题讨论】: