[R-sig-Geo] Issues with a GDB file in R?

Shaun Walbridge SWalbridge at esri.com
Wed May 2 19:52:56 CEST 2018


Hello Roman,

A couple of suggested options: You can try and use the arcgisbinding package [1] to pull the data directly into R via ArcGIS, as you mentioned you have ArcGIS available [presumably on Windows or in a VM]. It will access the data directly, and let you create sp and sf objects out of Geodatabases with little work. A basic workflow looks like this:

d <- arc.open("path/file.gdb/layer_name")
df <- arc.select(d) # here, you can filter columns and attributes, see [2]
# create an sf object
df.sf <- arc.data2sf(df)
# alternatively, create an sp object
df.sp <- arc.data2sp(df)

You can also write the results back to a geodatabase, or any other format that ArcGIS understands. Another option is trying the SpatiaLite version of the data at the URL you posted. You should be able to access this using R directly, provided your rgdal installation is correctly built to read spatialite databases. If it is, try the same process you mentioned using rgdal, but point it at the SpatialLite database instead. You could also use command-line OGR to convert the data, that has a few options like where clause filtering that aren't directly available via readOGR.

If neither of these options work, let me know and I can convert the data for you into a format of your preference.

Cheers,
Shaun

1. https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_R-2DArcGIS_r-2Dbridge-2Dinstall&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=fCPRb7QX-vd5bnO9gIJHCiX852SVUtyYX--xtCKtpfk&m=VcOyJ24SX8iVhqYGKDSOibdcFFiTWW3s5ctLZkiGYyY&s=dDYwxM4KOos8syBwUUUuSWLcyR4ZJlpdzbVvvfd28Oc&e=
2. https://urldefense.proofpoint.com/v2/url?u=https-3A__rdrr.io_github_R-2DArcGIS_r-2Dbridge_man_arc.select.html&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=fCPRb7QX-vd5bnO9gIJHCiX852SVUtyYX--xtCKtpfk&m=VcOyJ24SX8iVhqYGKDSOibdcFFiTWW3s5ctLZkiGYyY&s=oXh8b_5yVefz29INtNDKGdVJ86_GpF3gxuPY2aUOPyY&e=



On 5/2/18, 1:34 PM, "R-sig-Geo on behalf of Aguirre Perez, Roman" <r-sig-geo-bounces at r-project.org on behalf of ra454 at exeter.ac.uk> wrote:

    Hi everyone,
    
    I’ve been struggling with a ESRI Geodatabase file (clc12_Version_18_5.gdb) which is a layer of land cover classes available on
    
    https://urldefense.proofpoint.com/v2/url?u=https-3A__land.copernicus.eu_pan-2Deuropean_corine-2Dland-2Dcover_clc-2D2012-3Ftab-3Ddownload&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=qIGI8rXMP_JTDhSFz8NjjQMAyNAnpnUGFRBxqfH4bPU&s=9LaO4HiB5C5ewiuN_IeSQJSgq2tl5_-oMECPChtZa_U&e=
    
    whose size is 2.61 GB once unzipped.
    
    My ultimate task is to overlay it with the last NUTS3 administrative boundaries shapefile (2013) available on
    
    https://urldefense.proofpoint.com/v2/url?u=http-3A__ec.europa.eu_eurostat_web_gisco_geodata_reference-2Ddata_administrative-2Dunits-2Dstatistical-2Dunits&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=qIGI8rXMP_JTDhSFz8NjjQMAyNAnpnUGFRBxqfH4bPU&s=VExYSoR8FY_vhZaPNJpoOx0ZCZNMU9hMTtlGJZj2joU&e=
    
    in order to compute the area covered by each class within each NUTS3 region.
    
    Despite the ease of friendly software for performing this task, haven’t been capable of doing it - GRASS didn’t load the file as the log reports problems with the polygons, QGIS shows a warning regarding a specific object and ArcGIS got frozen. I guess it’s because the PC I used doesn’t have enough capacity. Unfortunately, I don’t have access to a more powerful one.
    
    Anyway, I decided to try with R -after all, I’ll perform my analysis with it. So I started exploring this GDB with rgdal:
    
    ogrInfo(dsn="clc12_Version_18_5.gdb",layer="clc12_Version_18_5")
    
    Source: "/Users/Roman/Desktop/clc12gdb/clc12_Version_18_5.gdb",
    layer: "clc12_Version_18_5"
    Driver: OpenFileGDB;
    number of rows: 2370829
    Feature type: wkbPolygon with 3 dimensions
    Extent: (-2693292 -3086662) - (10037210 5440568)
    Null geometry IDs: 2156240
    CRS: +proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs
    Number of fields: 6
    name                      type  length  typeName
    1 code_12              4       3           String
    2 ID                         4       18         String
    3 Remark               4       20         String
    4 Area_Ha             2       0           Real
    5 Shape_Length   2       0           Real
    6 Shape_Area       2       0           Real
    
    Then I tried to load it typing
    
    clc<-readOGR(dsn="clc12_Version_18_5.gdb",layer="clc12_Version_18_5")
    
    After 3-5 minutes, it appears the following text:
    
    OGR data source with driver: OpenFileGDB
    Source: "/Users/Roman/Desktop/clc12shp/clc12_Version_18_5.gdb", layer: "clc12_Version_18_5"
    with 2370829 features
    It has 6 fields
    
    Unfortunately, after trying 5 times (each one took around 8 hours) I couldn’t get anything but the following messages:
    
    Warning messages:
    1: In readOGR(dsn = "clc12_Version_18_5.gdb", layer = "clc12_Version_18_5") :
    Dropping null geometries: 2156240
    2: In readOGR(dsn = "clc12_Version_18_5.gdb", layer = "clc12_Version_18_5") :
    Z-dimension discarded
    
    Could anyone advise me how to tackle it? I also would appreciate suggestions on how to work with geodatabases - it’s my first time I work with these kind of files so I don’t even know their structure.
    
    By the way, these are my computer and software specifications:
    
    MacBook Pro 2012
    Processor 2.6 GHz Intel Core i7
    Memory 16 GB DDR3
    R 3.5.0
    RStudio 1.1.447
    
    
    Best,
    Roman.
       




More information about the R-sig-Geo mailing list