7

I have feature classes in a personal geodatabase on a Win 8.1 machine (r 3.4.2, rgdal 1.2-15) and, as mentioned here, there is a requirement for Access users to also interact with them.

I have adjusted the code sample found here (which works perfectly for a file geodatabase):

require(rgdal)

# The input personal geodatabase
pgdb <- "C:/path/to/your/personalgeodatabase.mdb"

# Confirm the PGeo driver is available
subset(ogrDrivers(), grepl("PGeo", name))

Which returns:

   name                 long_name write  copy isVector
49 PGeo ESRI Personal GeoDatabase FALSE FALSE     TRUE

Then, at this point, ogrListLayers(dsn) fails:

# List all feature classes in a personal geodatabase
fc_list <- ogrListLayers(pgdb)

Error in ogrListLayers(pgdb) : Cannot open data source

I have tried adding path.expand:

fc_list <- ogrListLayers(path.expand(pgdb))

And I have also confirmed that for gdal (and so rgdal), that

Personal Geodatabases are accessed by passing the file name of the .mdb file to be accessed as the data source name. On Windows, no ODBC DSN is required.

I successfully accessed the feature classes using R-ArcGIS but that requires an ArcGIS licence, and so does not really solve the problem.

Suggestions?

  • Can you use ogrinfo on the command line? I see more informative errors from that than from rgdal::ogrInfo, but I'm on Linux so I think my problem with a test PGeo is ODBC-related. – Spacedman Dec 19 '17 at 16:15
  • @spacedman thanks for the suggestion, I ran ogrInfo and it worked, then went back and ran orgListLarers and it surprisingly also worked!! (argh!) I can only suspect installing R-ArcGIS changed something during install as i believe that is the only thing that changed between composing the question and now. I'm pondering requesting that this question be closed... – wadlooper Dec 20 '17 at 18:35
  • Belay that close request option.. I just installed R on another machine (of course now @ r 3.4.2, rgdal 1.2-16), and ran the test code and again ogrListLayers, and ogrInfo, failed - I will not install R-ArcGIS on this other (Win 7) machine for now and have added a tag for r-bridge to this question. @Spacedman as suggested I ran ogrinfo from the command line and it failed but I suspect this result may send us off topic since I had this odd success with rgdal::ogrInfo (see previous comment) – wadlooper Dec 20 '17 at 19:52
  • Is the file also not open in Access? Can you point to a suitable example file? (I'd try reading as straight query with RODBC or odbc, then converting the binary list colum with sf tools - or trying with sf directly). I'd also test with GDAL command line tools, that's really the only way to isolate if there's an R problem, but assumes a bit of system installing. – mdsumner Dec 20 '17 at 20:06
  • 1
    @mdsumner - file was not also open in Access nor ArcGIS - I'm going with your 32-bit R answer as as the solution! – wadlooper Dec 21 '17 at 21:02
5

You are on Windows so I will assume you are on a 64-bit machine, running 64-bit R by default.

Try using rgdal::ogrListLayers from the 32-bit version of R, you can find it in the x86 folder of the /bin/ folder - parallel to the one x64 one I presume you are running. (Right click on the R shortcut for Properties to find it, or use R.home and trace from there. )

I'm sure that's required for this driver, I always have to run this mode of R for RODBC for these files. It's kind of "well-known" in that experts-only way of these things :)

  • Bingo - that's what changed when I installed R-ArcGIS, I switched to 32-bit R for full compatibility w/ArcGIS 10.x! thanks much @mdsumner – wadlooper Dec 21 '17 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.