【问题标题】:read multiple `.shp` file as one object?将多个“.shp”文件作为一个对象读取?
【发布时间】:2017-09-19 04:46:57
【问题描述】:

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

【问题讨论】:

  • 如果您将它们读取为空间多边形 data.frame,您可以按照建议 here 合并它们,如果没有,您可能需要寻找 arcpy 解决方案。

标签: r gis rgdal sf


【解决方案1】:
do.call(rbind, lapply(c("nc1", "nc2"), function(x) st_read("nc", layer = x)))

【讨论】:

    猜你喜欢
    • 2019-12-02
    • 1970-01-01
    • 2018-05-26
    • 1970-01-01
    • 2013-04-06
    • 1970-01-01
    • 2021-11-20
    • 1970-01-01
    • 2018-07-04
    相关资源
    最近更新 更多