[gdal-dev] reading rat values from GDB raster

William Kyngesburye woklist at kyngchaos.com
Wed Jul 19 07:26:45 PDT 2023


Ah, that works to get the xml rat.  I had converted to tif with Arc before I remembered that GDAL can read gdb rasters now, and got a dbf rat.

I can trim the xml rat down, but I need to leave the value field so it has some way to lookup a cell value in the rat, but identifying a cell (QGIS or gdallocationinfo) still only gives me the cell value not the rat lookup value.

Is there something else I need to do with the rat config?  What about the tableType attribute to GDALRasterAttributeTable? The conversion set "thematic". I tried removing it (like the example in the vrt help page) but that didn't help.

Here is the trimmed down xml rat header and first value:

<PAMDataset>
  <PAMRasterBand band="1">
    <GDALRasterAttributeTable tableType="thematic">
      <FieldDefn index="0">
        <Name>Value</Name>
        <Type>0</Type>
        <Usage>5</Usage>
      </FieldDefn>
      <FieldDefn index="1">
        <Name>World_Landform_Class</Name>
        <Type>1</Type>
        <Usage>0</Usage>
      </FieldDefn>
      <Row index="0">
        <F>1005</F>
        <F>1</F>
      </Row>
...

-----
William Kyngesburye
<kyngchaos*at*kyngchaos*dot*com>
<https://www.kyngchaos.com>

Don't Panic

> On Jul 18, 2023, at 5:31 PM, Even Rouault <even.rouault at spatialys.com> wrote:
> 
> William,
> 
> if you gdal_translate / CreateCopy() to a TIF, the RAT will be written in the side car .aux.xml file. You can either use your favorite XML edition tool to remove all columns but the one you are interested in, or use the C/C++/Python GDALRasterAttributeTable API to create a new RAT and copy values from the original one. https://github.com/OSGeo/gdal/blob/master/autotest/gcore/rat.py might serve as a starting point to get some sense of the API
> 
> Even
> 
>> Le 18/07/2023 à 23:19, William Kyngesburye a écrit :
>> I would like to convert a GDB raster with a multi column rat by writing out one of the columns. I can see the rat with gdalinfo but I can't figure out how to read values from the rat (other than the cell value) so they can be written to a new raster.
>> 
>> -----
>> William Kyngesburye
>> <kyngchaos*at*kyngchaos*dot*com>
>> <https://www.kyngchaos.com>
>> 
>> Don't Panic
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
> -- 
> http://www.spatialys.com
> My software is free, but my time generally not.
> 


More information about the gdal-dev mailing list