Opened 3 years ago

Last modified 3 years ago

#5741 new enhancement

FileGDB coded value domains

Reported by: Mike Toews Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

A problem with the current [Open]FileGDB drivers is that layers that use coded value domains show different attributes to that shown in ArcGIS.

Esri's description of coded value domains are described in XML Schema of the Geodatabase. A range domain type is also described in the whitepaper. Note that this is different than #4455, which describes a spatial domain.

So for example, I have a FileGDB layer that uses a field named DIP with type Short, and a coded value domain DipCategories with the following:

CodeDescription
1Low
0Unknown
3Shallow
2Moderate
4Steep

ArcGIS will show the Description only, and GDAL will show the Code only. Also, interestingly, exporting the FDB from ArcGIS to a Shapefile (using Esri tools) will only show the codes. Ideally, a read-only [Open]FileGDB GDAL driver would identify the columns that use coded value domains, change their schema to match the description, and use the description in place of the code. Essentially, the result would be the same when viewing the attributes in ArcGIS.

From what I see, the coded domain descriptions are in a00000004.gdbtable, and this table can be accessed using the OpenFileGDB driver. So where name='DipCategories', the definition is (xmlprettyprint):

<?xml version="1.0"?>
<GPCodedValueDomain2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:typens="http://www.esri.com/schemas/ArcGIS/10.0" xsi:type="typens:GPCodedValueDomain2">
<DomainName>DipCategories</DomainName>
<FieldType>esriFieldTypeSmallInteger</FieldType>
<MergePolicy>esriMPTDefaultValue</MergePolicy>
<SplitPolicy>esriSPTDefaultValue</SplitPolicy>
<Description>Valid Dip Categories</Description>
<Owner/>
<CodedValues xsi:type="typens:ArrayOfCodedValue">
    <CodedValue xsi:type="typens:CodedValue">
        <Name>Low</Name>
        <Code xsi:type="xs:short">1</Code>
    </CodedValue>
    <CodedValue xsi:type="typens:CodedValue">
        <Name>Unknown</Name>
        <Code xsi:type="xs:short">0</Code>
    </CodedValue>
    <CodedValue xsi:type="typens:CodedValue">
        <Name>Shallow</Name>
        <Code xsi:type="xs:short">3</Code>
    </CodedValue>
    <CodedValue xsi:type="typens:CodedValue">
        <Name>Moderate</Name>
        <Code xsi:type="xs:short">2</Code>
    </CodedValue>
    <CodedValue xsi:type="typens:CodedValue">
        <Name>Steep</Name>
        <Code xsi:type="xs:short">4</Code>
    </CodedValue>
</CodedValues>
</GPCodedValueDomain2>

Attachments (1)

composite.png (80.1 KB) - added by Mike Toews 3 years ago.
shows attributes from QGIS and ArcGIS

Download all attachments as: .zip

Change History (4)

comment:1 Changed 3 years ago by Jukka Rahkonen

I would say that if I had to select either the code or the description I would take the codes just like GDAL and ESRI when it saves data into shapefiles. Description are good for humans but code values often make sense in queries "select * where steepness_class >= 2". Also for in multilingual countries and in international usage there can be a need to use several human readable descriptions.

Rather than using descriptions instead of codes I could think about two alternatives:

  • Have an option to expand the schema and write also a description field in addition to the code field which is the default and always present
  • Make a dedicated tool for converting FileGDB data into other databases (Oracle, PostGIS, Spatialite, GeoPackage ...) Then again the spatial tables would contain the "code" field but the DipCategories? would be written into their own table. Connecting the code to the description could be done with relations.

Changed 3 years ago by Mike Toews

Attachment: composite.png added

shows attributes from QGIS and ArcGIS

comment:2 Changed 3 years ago by Mike Toews

I've attached a composite screenshot from various dialogs from QGIS, using the OpenFileGDB driver, and ArcGIS 10.0. The are viewing the same data source, but are presented differently.

shows attributes from QGIS and ArcGIS

Esri mix either the code or description in various contexts, as shown above. I don't think translations for multilingual countries is covered by Esri, so I would't worry about that.

I think at bare minimum, the coded value domains from a00000004.gdbtable or GDB_Items should be exposed as really simple tables. (For what it's worth, the Esri tool for this is Domain To Table (Data Management), and this recipe shows how to export all attribute domains into tables).

This way, a user can at least access the information from the coded value domain, for example with SQL:

SELECT DipCategories.description AS DIP
FROM my_layer
LEFT JOIN DipCategories ON DipCategories.code=my_layer.DIP

comment:3 Changed 3 years ago by sfkeller

I'd like to support mwtoews proposal to expose a coded value domain as a simple lookup table.

Be aware that ArcGIS 10 help [1] says that there are two domain types (range domain and coded domain) and that "A coded value domain can apply to any type of attribute" (short/long integers, float, double, text and date).

[1] http://resources.arcgis.com/en/help/main/10.2/index.html#//001s00000001000000

Note: See TracTickets for help on using tickets.