sf错误:OGR错误:无法导出到WKT

问题描述 投票:0回答:1

我在计算机上运行

sf
时遇到问题(R 版本 4.3.3,linux ubuntu 22.04.4)。当尝试使用
st_read()
导入 shapefile 时,我遇到以下错误和警告消息:

> parks <- sf::st_read("Canada/PAs/ProtectedConservedArea_2023.gdb")

Multiple layers are present in data source /run/user/1472454/gvfs/smb-share:server=files.ok.ubc.ca,share=rsmarcus/GitHub/NDVI/Canada/PAs/ProtectedConservedArea.gdb, reading layer `ProtectedConservedArea'.
Use `st_layers' to list all layer names and their type in a data source.
Set the `layer' argument in `st_read' to read a particular layer.
Reading layer `ProtectedConservedArea' from data source 
  `/Canada/PAs/ProtectedConservedArea.gdb' using driver `OpenFileGDB'

Error: OGR error: cannot export to WKT
In addition: Warning messages:
1: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
  automatically selected the first layer in a data source containing more than one.
2: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
  GDAL Message 1: organizePolygons() received a polygon with more than 100 parts. The processing may be really slow.  You can skip the processing by setting METHOD=SKIP, or only make it analyze counter-clock wise parts by setting METHOD=ONLY_CCW if you can assume that the outline of holes is counter-clock wise defined
3: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
  GDAL Error 1: PROJ: proj_as_wkt: std::bad_alloc

我当前正在运行

sf
版本 1.0-16(使用 GEOS 3.12.1、GDAL 3.8.4 和 PROJ 9.3.1) - 这些错误仅在不久前更新我的软件包后出现。在更新我的包之前,我能够毫无问题地使用所有
sf
功能,包括导入完全相同的 shapefile。我已尝试更新所有包,以防这是依赖项问题(使用
update.packages()
函数),但这并没有解决问题。

我附上了一行使用加拿大保护区形状文件的可重现代码,可以在此处获取:https://data-donnees.az.ec.gc.ca/data/species/protectrestore/canadian-protected -保守区域数据库/数据库

library('sf')
parks <- sf::st_read("Canada/PAs/ProtectedConservedArea_2023.gdb")

我希望解决这个问题,而不必安装旧版本的软件包来运行我的代码!

r spatial shapefile r-sf
1个回答
0
投票

好的,经过多次重新安装

sf
,我能够让它工作了。我相信这个问题与 GDAL 安装有关 - 我使用here描述的步骤再次安装了 GDAL,之后我能够成功加载和使用
sf

© www.soinside.com 2019 - 2024. All rights reserved.