如何更改 R 中 .shp 文件的坐标参考系统 (CRS)?
How to change coordinate reference system (CRS) for a .shp file in R?
我有一个 .shp 文件,我想更改它的 crs
,我曾尝试使用 spTransform
,但它在我的情况下不起作用。可以在 https://www.dropbox.com/s/8wfgf8207dbh79r/gpr_000b11a_e.zip?dl=0 找到 .shp 文件。
library(rgdal)
shpfile <- readOGR(dsn="D:/Map",layer = "gpr_000b11a_e")
crs(shpfile)
CRS arguments:
+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0
spTransform(shpfile, CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
crs(shpfile)
CRS arguments:
+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0
问题是:在 spTransform
之后,shapefile 的 crs 没有改变。感谢您的帮助。
问题是您没有将变换后的形状归因于对象。
试试这个:
shpfile <- spTransform(shpfile,
CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
我向您推荐包 sf
,用于读取和处理 .shp
个文件,它易于使用且高效。
希望对您有所帮助。
我有一个 .shp 文件,我想更改它的 crs
,我曾尝试使用 spTransform
,但它在我的情况下不起作用。可以在 https://www.dropbox.com/s/8wfgf8207dbh79r/gpr_000b11a_e.zip?dl=0 找到 .shp 文件。
library(rgdal)
shpfile <- readOGR(dsn="D:/Map",layer = "gpr_000b11a_e")
crs(shpfile)
CRS arguments:
+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0
spTransform(shpfile, CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
crs(shpfile)
CRS arguments:
+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0
问题是:在 spTransform
之后,shapefile 的 crs 没有改变。感谢您的帮助。
问题是您没有将变换后的形状归因于对象。 试试这个:
shpfile <- spTransform(shpfile,
CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
我向您推荐包 sf
,用于读取和处理 .shp
个文件,它易于使用且高效。
希望对您有所帮助。