r - 如何使用 st_write 将 sf 对象作为 shapefile 写入 ESRI 文件地理数据库?
问题描述
如何使用 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
;写入地理数据库。你只能阅读它们。
你有几个选择。您可以使用以下命令将数据保存为地理数据库之外的 shapefile(或任何其他空间数据格式)sf
:
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)
arcgisbinding
可以在此处找到有关 R-ArcGIS Bridge(和包)的详细信息。
推荐阅读
- python - 如何用 Python 中看似有效的 s 表达式来修复解析错误?
- scala - 从现有 DataFrame 创建嵌套数组 DataFrame
- java - 如何自动将“实施”行添加到新项目
- usb - 可以通过远程桌面共享 ST-LINK 的 USB 端口吗?
- r - 如何在R中使用两个模式对象grepl
- sklearn-pandas - 如何识别在流失阶段没有拨打/使用过呼入电话、呼出电话和互联网的客户?
- c# - WPF - 如何关闭在 RichTextBox 中打开的文件
- scala - 如何获得 AST 所代表的值的类型?
- c# - 如何从它自己的类从十进制转换为整数?
- java - 任何人都可以帮助纠正我及时倒退的方法吗?