提取与多线串重叠的栅格像元的坐标

Extract coordinates of raster cells that overlap with multilinestring

我正在使用 R,我有一个栅格 (population),每个像元都有人口密度数据,还有一个代表国际边界的多线串 (border_365_366)。我想提取与国际边界重叠的栅格单元格的坐标。 有谁知道如何提取这个?我认为这里的主要问题之一是我正在使用多字符串而不是带坐标的 data.frame。

> class(border_365_366)
[1] "sf"         "data.frame"

> class(population)
[1] "RasterLayer"
attr(,"package")

[1] "raster"
> border_365_366
Simple feature collection with 1 feature and 0 fields
geometry type:  MULTILINESTRING
dimension:      XY
bbox:           xmin: 27.32998 ymin: 57.52933 xmax: 28.21014 ymax: 59.46253
geographic CRS: WGS 84
                        geometry
1 MULTILINESTRING ((27.66656 ...

> population
class      : RasterLayer 
dimensions : 21600, 34926, 754401600  (nrow, ncol, ncell)
resolution : 0.01030751, 0.01046373  (x, y)
extent     : -180, 180, -120.053, 105.9636  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +datum=WGS84 +no_defs 
names      : pop_new 
values     : 0, 107475  (min, max)

我能够通过将线转换为线串来解决这个问题

border_365_366<- st_cast(border_365_366,'LINESTRING')