I have a a big feature class in geodatabase (~1.3 million rows and 234 columns; you could download it using this link) in ArcGIS 10.4.1.

I want to import the feature class from the geodatabase to R and plot specific variables (using ggplot2).

I tried importing it into R, using the answer of this question, as below

# The input file geodatabase
fgdb = "C:/Question_Online/union_question.gdb"
# List all feature classes in a file geodatabase
subset(ogrDrivers(), grepl("GDB", name))
fc_list = ogrListLayers(fgdb)
# Read the feature class
fc = readOGR(dsn=fgdb,layer="union_thirdtrial")

However, it took more than an hour, so I had to close RStudio to terminate the process.

Can anyone point out what I am missing for a better (faster) way to import this feature class to R?

1 Answer 1


You can use st_read from the sf package. It reads the GeoDatabase as a SimpleFeatures object, which you can convert to SpatialPolygonsDataFrame using the as() method. One caveat: the conversion does not allow for a Z-dimension, so you have to drop it.

I read your union_question.gdb in ~ 15 minutes with st_read(). The conversion to SPDF took 11 minutes.


x <- st_read(dsn="union_question.gdb")
y <- st_drop_zm(x)
z <- as(y, "Spatial")
  • Thanks for your time and help. I got this error after running z <- as(y, "Spatial") Error: cannot allocate vector of size 14 Kb. I will appreciate any help how to fix it.
    – shiny
    Jan 11, 2017 at 22:42
  • That sounds like a memory issue. Either you need more physical RAM, or you can try to increase R's memory by observing the output of memory.limit(), and then increasing it with memory.limit(size = x). Jan 11, 2017 at 23:19
  • Thanks for your help. I'm using Windows 7 64-bit and my PC has 16 GB RAM. I checked memory.limit() [1] 16264 I think this means it is 16264 Mb which is higher than the actual memory of my PC. I think this means I don't need to increase it. Any feedback will be appreciated.
    – shiny
    Jan 12, 2017 at 0:56
  • 1
    Then unfortunately I'm not sure what the problem is. Consider saving a copy of the GDB containing only the fields you need to plot in R. Jan 16, 2017 at 16:10
  • 1
    I have 8 GB memory, so that's not your problem. I'm not sure how to help you further. I would suggest figuring out how to make a copy of your GDB with only necessary fields, but it's hard to provide help for that (at least without further information). Jan 16, 2017 at 22:00

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.