1

I am trying to read a table from an ESRI geodatabase (.gdb) that has no geometry using R. readOGR is throwing an error because there is no geometry defined, which kind of make sense:

 # Load module to get readOGR
 require('rgdal');

 # Load module to get read.dbf
 require('foreign');

Le chargement a nécessité le package : 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

----------

The same code with another layer (that is a shapefile) like PEE_MAJ works.

 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

Could you please help me to read features contained in the ESSENCE_MAJ table ?

hhh
  • 50,788
  • 62
  • 179
  • 282
  • Did you get this resolved? I am trying to find out how to read a zipped GDB file. – hhh Oct 09 '20 at 15:18

1 Answers1

1

I had the same problem. My current solution is to directly call the OGR library from R and dump the content of the table into a csv that I read back in R:

system("ogr2ogr -f CSV ESSENCE_MAJ.csv Produits_IEQM_04151.gdb ESSENCE_MAJ")

See here for more info. It was on a unix machine, not quite sure about the exact command to call ogr2ogr on Windows. Hope it helps!

Community
  • 1
  • 1
brunj7
  • 149
  • 1
  • 8