如何使用st_write将SF对象作为shapefile写入ESRI文件地理数据库?

rha*_*fer 5 r esri r-sf

如何使用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")
Run Code Online (Sandbox Code Playgroud)

haf*_*aff 7

这里有几件事:首先,您不能将 shapefile 写入 ESRI 地理数据库,因为那里只能存储要素类和要素数据集。其次,您不能通过sf;写入地理数据库;你只能阅读它们。

你有几个选择。您可以使用以下命令将数据保存为地理数据库之外的 shapefile(或任何其他空间数据格式)sf

library(sf)

## it will guess the driver automatically based on the .shp extension
st_write(sf.object, "data/my_shapefile.shp")
Run Code Online (Sandbox Code Playgroud)

或者,如果您绝对需要写入地理数据库,则可以使用该arcgisbinding库,但请注意,您需要使用具有活动 ArcGIS 许可的计算机。因此,这在 GNU/Linux 和 Mac 上是行不通的。

我无法验证这是否有效,因为我使用的是 GNU/Linux,但它应该是这样的:

library(arcgisbinding)

arc.write("data.gdb/fc", sf.object)
Run Code Online (Sandbox Code Playgroud)

arcgisbinding可以在此处找到有关 R-ArcGIS Bridge(和包)的详细信息。