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

Tde*_*eus 5 gis r geospatial map-projections r-sf

我正在尝试为我的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
Run Code Online (Sandbox Code Playgroud)

输出:

在此处输入图片说明

该层具有正确的投影。

但是该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
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

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

seb*_*rno 9

此外,还有st_set_crs()可以在管道中使用的功能。例如,

points %>% st_set_crs(st_crs(polygons))

  • 我在包“sf”中找不到函数“st_set_crs”。现在这已经过时了吗? (2认同)

lok*_*oki 5

您可以使用st_crs

如示例中所述:

st_crs(x) <- value 
Run Code Online (Sandbox Code Playgroud)

在您的情况下,可能是

st_crs(points) <- st_crs(polygons)
Run Code Online (Sandbox Code Playgroud)

注意:当然,这些点应在同一坐标系中注册。如果不是,则必须为它们找到正确的坐标系,然后使用st_transform它们将其置于与多边形相同的坐标系中。