如何使用 st_write 将 sf 对象作为 shapefile 写入文件地理数据库?
我不太明白与文件地理数据库相关的 st_write 的“dsn”、“layer”和“driver”参数。
例如,我已经尝试了这两个,但没有运气
st_write(sf.object, dsn = "filepath/FileGeoDatabase.gbd",layer="name of output layer", driver="OpenFileGDB")
st_write(sf.object, dsn = "filepath/FileGeoDatabase.gbd",layer="name of output layer", driver="ESRI Shapefile")
最佳答案
这里有几件事:首先,您不能将 shapefile 写入 ESRI 地理数据库,因为那里只能存储要素类和要素数据集。其次,您不能通过 sf
写入地理数据库;你只能阅读它们。
你有几个选择。您可以使用 sf
将数据保存为地理数据库之外的 shapefile(或任何其他空间数据格式)。 :
library(sf)
## it will guess the driver automatically based on the .shp extension
st_write(sf.object, "data/my_shapefile.shp")
或者,如果您绝对需要写入地理数据库,则可以使用
arcgisbinding
库,但请注意,您需要使用具有事件 ArcGIS 许可的计算机。因此,这在 GNU/Linux 和 Mac 上是行不通的。我无法验证这是否有效,因为我使用的是 GNU/Linux,但它应该是这样的:
library(arcgisbinding)
arc.write("data.gdb/fc", sf.object)
有关 R-ArcGIS Bridge(和
arcgisbinding
包)的详细信息可以在 here 中找到。 .
关于r - 如何使用 st_write 将 sf 对象作为 shapefile 写入 ESRI 文件地理数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51622200/