我正在尝试从ESRI地理数据库(.gdb)中读取一个没有使用R的几何体的表.readOGR因为没有定义几何体而引发错误,哪种有意义:
# Load module to get readOGR
require('rgdal');
# Load module to get read.dbf
require('foreign');
le chargementannécessitélepackage:foreign
# goto the directory with the GDB files
fgdb <- "c:/Mrnmicro/VulnerabilitePeuplements/gdb/Produits_IEQM_04151.gdb"
# List all feature classes in a file geodatabase
subset(ogrDrivers(), grepl("GDB", name))
name long_name write copy isVector
34 OpenFileGDB ESRI FileGDB FALSE FALSE TRUE
ogrListLayers(fgdb)
[1] "ESSENCE_MAJ" "ETAGE_MAJ" "Perimetre" "PEE_MAJ" "META_MAJ"
attr(,"driver")
[1] "OpenFileGDB"
attr(,"nlayers")
[1] 5
# Read the feature class
fc = readOGR(dsn=fgdb,layer="ESSENCE_MAJ",dropNULLGeometries=FALSE)
Error in readOGR(dsn = fgdb, layer = "ESSENCE_MAJ", dropNULLGeometries = FALSE) :
no features found
In addition: Warning message:
In ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, :
ogrInfo: all features NULL
----------
与PEE_MAJ之类的另一层(即shapefile)相同的代码可以正常工作。
fc = readOGR(dsn=fgdb,layer="PEE_MAJ",dropNULLGeometries=FALSE)
OGR data source with driver: OpenFileGDB
Source: "c:/Mrnmicro/VulnerabilitePeuplements/gdb/Produits_IEQM_04151.gdb", layer: "PEE_MAJ"
with 135202 features
It has 31 fields
您能否帮我阅读ESSENCE_MAJ表中的功能?
答案 0 :(得分:2)
我遇到了同样的问题。我目前的解决方案是直接从R调用OGR库并将表的内容转储到我在R中读回的csv中:
system("ogr2ogr -f CSV ESSENCE_MAJ.csv Produits_IEQM_04151.gdb ESSENCE_MAJ")
有关详细信息,请参阅here。它是在一台unix机器上,不太确定在Windows上调用ogr2ogr的确切命令。希望它有所帮助!