读多个`.shp`文件作为一个对象?

时间:2017-04-22 04:39:35

标签: r gis rgdal sf

如何将多个.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)

1 个答案:

答案 0 :(得分:3)

do.call(rbind, lapply(c("nc1", "nc2"), function(x) st_read("nc", layer = x)))
相关问题