【发布时间】:2013-07-19 14:14:29
【问题描述】:
我发现了两种在 R 中打开 shapefile 的基本方法 - 使用 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!
我是否可以得出结论,这两种方法是等效的,但使用 rgdal 打开 shapefile 总是更安全?
【问题讨论】:
标签: r gis shapefile rgdal maptools