我找到了两种在R中打开shapefiles的基本方法--使用rgdal和maptools
# 1
require(maptools)
shape_maptools <- readShapeLines("file.shp")
# 2
require(rgdal)
shape_rgdal <- readOGR(".", "file")在这两种情况下,数据结构似乎完全相同(类SpatialLinesDataFrame、包sp)。但是,在rgdal reads the projection properly, maptools does not时(您可能需要手动分配CRS ):
> proj4string(shape_maptools)
[1] NA
> proj4string(shape_rgdal)
[1] "+proj=utm +zone=31 +ellps=intl +units=m +no_defs"那么,为什么我要使用maptools来打开形状文件呢?我可能只会犯手动分配CRS的错误!
发布于 2013-10-15 05:07:51
以下是来自国家生态分析与合成中心的maptools,rgdal和PBSMapping的比较,你可能会感兴趣:
"Read and write ESRI Shapefiles with R"
发布于 2013-07-26 18:00:41
maptools::readShapeLines()在包含空格字符的文件名中遇到问题,例如。德语乌姆劳特。
rgdal可以处理这样的情况。
https://stackoverflow.com/questions/17760561
复制相似问题