【问题标题】:How to import projection in readShapePoly() function? - R如何在 readShapePoly() 函数中导入投影? -R
【发布时间】:2013-10-13 03:07:50
【问题描述】:

我正在从 Arcmap 导入一个多边形 shapefile,该文件已经有一个投影集并附带了它的所有文件(sbn、sbx、prj 等)。

但是,在我使用 readShapePoly 函数后,当我进行摘要时,投影信息看起来是空白的。投影是否已包含或未被识别?

Object of class SpatialPolygonsDataFrame
Coordinates:
        min     max
x   35551.4 1585917
y 6318047.3 9408727
Is projected: NA 
proj4string : [NA]
Data attributes:

我知道有一个proj4string 属性,但不清楚如何使用它以及它已经附加到 .shp 文件的 prj 文件。如果有另一个功能,我可以考虑另一个做得更好的功能。不确定rgdalreadOGR 是否符合我的要求。

编辑跟进:我尝试了readOGR,感谢您的回复。我正在使用此代码 test

【问题讨论】:

  • 是的。使用readOGR(),因为它会保留/捕获投影信息。
  • @JoshO'Brien 我刚刚尝试了 readOGR,但它没有加载投影。在帮助页面中它指出“PROJ4 字符串定义 CRS,如果默认为 NULL,则从 OGR 数据集中读取值”
  • @JoshO'Brien 我也尝试过使用 OGRSpatialRef,但它没有获取 .prj 文件。
  • 嗯。那就帮不了你了。如果您用于调用这些函数的语法没有错误,并且您的 shapefile 格式正确,那么这应该可以工作。例如,尝试使用map <- readOGR(dsn = system.file("vectors", package="rgdal"), layer="scot_BNG"); proj4string(map)OGRSpatialRef(dsn = system.file("vectors", package="rgdal"), layer="scot_BNG") 来查看这些函数的预期行为。它保留投影信息的事实是更喜欢 rgdal 而不是 maptools 进行数据导入的一大原因。

标签: r shapefile map-projections maptools


【解决方案1】:

如果您必须使用 RShapePoly,请尝试以下方法:

读取 shapefile 上的投影:

proj4string(yourshapefile.pr) 

[1] "+init=epsg:2163 +proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs"

现在投影它

yourshapefile.pr <- spTransform(yourshapefile, CRS( "+init=epsg:2163" )) #US National Atlas Equal Area

【讨论】:

  • 很遗憾我现在无法测试这个,如果有人能够测试它并且它有效,我可以将答案标记为正确。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-11
  • 2017-01-18
  • 1970-01-01
  • 2014-06-17
  • 2020-09-18
  • 2020-11-22
相关资源
最近更新 更多