我想使用sf::st_transform()
重新投影我的sf对象,但是转换后的对象的投影与我在转换调用中指定的投影不一样。为什么?为什么?
library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
# target proj4string
my_crs <- "+proj=lcc +lat_1=40.66666666666666 +lat_2=41.03333333333333 +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs"
# create test sfc
p1 <- st_sfc(st_point(c(1,2)), crs = "+init=epsg:3857")
# re-project p1 to `my_crs`
p2 <- st_transform(p1, crs = my_crs)
all.equal(my_crs, st_crs(p2)$proj4string)
#> [1] "1 string mismatch"
st_crs(p2)
#> Coordinate Reference System:
#> No EPSG code
#> proj4string: "+proj=lcc +lat_1=40.66666666666666 +lat_2=41.03333333333333 +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs"
这两个投影之间唯一的区别是proj 4字符串中的+x_0
元素。在p2
的投影中,尾部的1 e-10已经被删除。
1条答案
按热度按时间muk1a3rh1#
sf::st_transform()
使用GDAL进行投影。帮助页面声明:GDAL不支持某些PROJ.4预测,例如
"+proj=wintri"
,因为它没有逆投影。投影到不支持的投影可以通过lwgeom
包的一部分st_transform_proj
完成。请注意,不支持的proj4string不能作为参数传递给st_crs
,但必须作为字符串给出。如果您在示例中使用PROJ.4进行投影,则它可以正常工作:
我对制图学的了解不多,不知道这种差异是由于帮助页面中提到的逆投影问题还是其他原因造成的。
相关信息:
https://stackoverflow.com/a/51663647/1707525
https://github.com/r-spatial/sf/issues/810
https://github.com/r-spatial/sf/issues/1019