0

I'm trying to get an ESRI File Geodatabase domains by using the GDAL\OGR library. By doing so, I wish to edit this datasource using QGIS' Attributes Form with designated value map widgets that point to this domains.

I'm familiar with QGIS\OGR's capabilities of opening, viewing and even altering File Geodatabase (using FileGDB driver). What's missing is the ability to extract the properties of the FGDB itself - such as 'domains'.

Is there any way to extract FileGDB domains only using OSGeo programs without the help of ArcGIS software?

  • I don't know about "domains" but you should be able to open and view a filegdb directly in QGIS, just like you would any other vector file. However, you will have to save it in another format before you can edit it. Eg, geopackage, sqlite database, shapefile, etc. – csk Jun 6 at 18:50
  • Thank you for the comment @csk. I'm familiar with QGIS\OGR's capabilities of opening, viewing and even altering File Geodatabase (you should take a look in the FileGDB driver). Nonetheless I'm still missing the ability to extract the properties of the FGDB itself - such as 'domains'. – EranGeo Jun 9 at 8:32
  • Thanks for clarifying. I wasn't sure if that solution worked for domains or not. I updated your question to mention that you tried the FileGDB driver and it didn't work for domains and other properties. – csk Jun 10 at 17:10
  • Thank you for editing @csk. It's much clearer now. – EranGeo Jun 11 at 6:41
1

I am not sure if GeoCat Bridge can help you. What I know about this software is it can translate mxd and other tricky ArcGIS data files to other FOSS4GIS softwares. There are some information here: https://www.youtube.com/watch?v=uEAchftdDVA Please keep us informed of your results if you test that solution.

  • Thank you for the suggestion @Gabriel Asato. There's one major problem: It's proprietary (and too expensive for me). Moreover I think this service focuses mainly in converting projects into spatial web services such as Geoserver. – EranGeo Jun 9 at 8:52
0

I found a perfect answer for my question in a post I found in Alex Tereshenkov's blog. The post contains a python script for printing the FGDB's domains in python interpreter:

from __future__ import print_function
import json
import xml.etree.ElementTree as ET
import ogr

gdb_path = r'C:\GIS\data\Adv.gdb'
ds = ogr.Open(gdb_path)
res = ds.ExecuteSQL('select * from GDB_Items')
res.CommitTransaction()

for i in xrange(0, res.GetFeatureCount()):
    item = json.loads(
        res.GetNextFeature().ExportToJson())['properties']['Definition']
    if item:
        xml = ET.fromstring(item)
        if xml.tag == 'GPCodedValueDomain2':
            print(xml.find('DomainName').text)
            print(xml.find('Description').text)
            print(xml.find('FieldType').text)

            for table in xml.iter('CodedValues'):
                for child in table:
                    print(child.find('Code').text, child.find('Name').text)
            print()

        if xml.tag == 'GPRangeDomain2':
            print(xml.find('DomainName').text)
            print(xml.find('Description').text)
            print(xml.find('FieldType').text)
            print(xml.find('MinValue').text)
            print(xml.find('MaxValue').text)

# Domain1
# Desc1
# esriFieldTypeString
# a aa
# b bb

# Domain2
# Desc2
# esriFieldTypeInteger
# 1 aa
# 2 bb
# 3 cc

# Domain3
# Desc3
# esriFieldTypeInteger
# 0
# 100

make sure you've got python's ogr package installed.


Furthermore, as I explored his blog, I found a more encompassing tool he made for exploring ESRI GDB's properties. This tool makes an HTML report of the GDB's properties. Make sure you follow his instructions in the tool's repository

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.