如何将 sf 对象绑定在一起
How to bind together sf objects
我有一个 POLYGON
的列表,我想用单个几何列多边形创建一个 tibble。
my_list <- list(structure(list(structure(list(structure(c(1046881.53939377,
1049327.5242989, 1049327.5242989, 1046881.53939377, 1046881.53939377,
5704036.79875299, 5704036.79875299, 5706482.78365812, 5706482.78365812,
5704036.79875299), .Dim = c(5L, 2L))), class = c("XY", "POLYGON",
"sfg"))), class = c("sfc_POLYGON", "sfc"), precision = 0, bbox = structure(c(xmin = 1046881.53939377,
ymin = 5704036.79875299, xmax = 1049327.5242989, ymax = 5706482.78365812
), class = "bbox"), crs = structure(list(epsg = 3857L, proj4string = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"), class = "crs"), n_empty = 0L),
structure(list(structure(list(structure(c(1044435.55448865,
1046881.53939377, 1046881.53939377, 1044435.55448865, 1044435.55448865,
5706482.78365812, 5706482.78365812, 5708928.76856324, 5708928.76856324,
5706482.78365812), .Dim = c(5L, 2L))), class = c("XY", "POLYGON",
"sfg"))), class = c("sfc_POLYGON", "sfc"), precision = 0, bbox = structure(c(xmin = 1044435.55448865,
ymin = 5706482.78365812, xmax = 1046881.53939377, ymax = 5708928.76856324
), class = "bbox"), crs = structure(list(epsg = 3857L, proj4string = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"), class = "crs"), n_empty = 0L))
我试过了
tibble(result = do.call(rbind, muylist[1:2]))
# A tibble: 2 x 1
result[,1]
<list>
1 <XY>
2 <XY>
我愿意:
result[,1]
<list>
1 <POLYGON [m]>
2 <POLYGON [m]>
library(sf)
result <- do.call(rbind, lapply(my_list, st_sf))
result[,1]
Simple feature collection with 2 features and 0 fields
geometry type: POLYGON
dimension: XY
bbox: xmin: 1044436 ymin: 5704037 xmax: 1049328 ymax: 5708929
CRS: EPSG:3857
X..i..
1 POLYGON ((1046882 5704037, ...
2 POLYGON ((1044436 5706483, ...
我有一个 POLYGON
的列表,我想用单个几何列多边形创建一个 tibble。
my_list <- list(structure(list(structure(list(structure(c(1046881.53939377,
1049327.5242989, 1049327.5242989, 1046881.53939377, 1046881.53939377,
5704036.79875299, 5704036.79875299, 5706482.78365812, 5706482.78365812,
5704036.79875299), .Dim = c(5L, 2L))), class = c("XY", "POLYGON",
"sfg"))), class = c("sfc_POLYGON", "sfc"), precision = 0, bbox = structure(c(xmin = 1046881.53939377,
ymin = 5704036.79875299, xmax = 1049327.5242989, ymax = 5706482.78365812
), class = "bbox"), crs = structure(list(epsg = 3857L, proj4string = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"), class = "crs"), n_empty = 0L),
structure(list(structure(list(structure(c(1044435.55448865,
1046881.53939377, 1046881.53939377, 1044435.55448865, 1044435.55448865,
5706482.78365812, 5706482.78365812, 5708928.76856324, 5708928.76856324,
5706482.78365812), .Dim = c(5L, 2L))), class = c("XY", "POLYGON",
"sfg"))), class = c("sfc_POLYGON", "sfc"), precision = 0, bbox = structure(c(xmin = 1044435.55448865,
ymin = 5706482.78365812, xmax = 1046881.53939377, ymax = 5708928.76856324
), class = "bbox"), crs = structure(list(epsg = 3857L, proj4string = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"), class = "crs"), n_empty = 0L))
我试过了
tibble(result = do.call(rbind, muylist[1:2]))
# A tibble: 2 x 1
result[,1]
<list>
1 <XY>
2 <XY>
我愿意:
result[,1]
<list>
1 <POLYGON [m]>
2 <POLYGON [m]>
library(sf)
result <- do.call(rbind, lapply(my_list, st_sf))
result[,1]
Simple feature collection with 2 features and 0 fields
geometry type: POLYGON
dimension: XY
bbox: xmin: 1044436 ymin: 5704037 xmax: 1049328 ymax: 5708929
CRS: EPSG:3857
X..i..
1 POLYGON ((1046882 5704037, ...
2 POLYGON ((1044436 5706483, ...