将正确的坐标系设置在SF对象上以绘制坐标点

15

我正在尝试为我的 sf 对象定义正确的CRS。我想在以下图层(国家:荷兰)之上绘制点:

Simple feature collection with 380 features and 3 fields
geometry type:  MULTIPOLYGON
dimension:      XY
bbox:           xmin: 13565.4 ymin: 306846.2 xmax: 278026.1 ymax: 619232.6
epsg (SRID):    NA
proj4string:    +proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +no_defs

输出:

在这里输入图像描述

这一层有正确的投影。

但是POINT图层没有正确的CRS投影,可能是因为它没有proj4string

Simple feature collection with 566 features and 5 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: 3.5837 ymin: 50.86487 xmax: 7.120998 ymax: 53.44835
epsg (SRID):    NA
proj4string:    NA

如何设置与前一个地图相同的投影方式,以便在其上绘制坐标点?

enter image description here

2个回答

22
此外,还有一个名为st_set_crs()的函数,可以在管道中使用。例如,points %>% st_set_crs(st_crs(polygons))

2
我在sf包中找不到st_set_crs函数。这个函数现在已经过时了吗? - mikey
看起来这是 geotidy 包的一部分。 - Maël
sf::st_set_crs() 存在。 - Jessica Burnett

11
你可以使用st_crs。正如示例中所说:
st_crs(x) <- value 
在您的情况下,可能是这样的。
st_crs(points) <- st_crs(polygons)

注意:当然,这些点应该在同一个坐标系中注册。如果不是,则需要找到正确的坐标系,然后使用st_transform将它们放入与多边形相同的坐标系中。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接