0

如何将多个.shp文件作为一个对象读取?

我想像在代码下一样简单地阅读。

nc <- st_read(dsn = "nc",
              layer = c("nc1","nc2"))

将多个文件作为对象读取的最佳方法是什么?

library(sf)
nc <- st_read(system.file("shape/nc.shp", package="sf"))

nc1 <- nc[1:50, ]
nc2 <- nc[51:100, ]

st_write(nc1,
         dsn = "nc",
         layer = "nc1",
         driver = "ESRI Shapefile")

st_write(nc2,
         dsn = "nc",
         layer = "nc2",
         driver = "ESRI Shapefile",update = T)
4

1 回答 1

4
do.call(rbind, lapply(c("nc1", "nc2"), function(x) st_read("nc", layer = x)))
于 2017-06-03T08:35:47.757 回答