[gdal-dev] GEOTIFF with RAT - transformation unsuccessful (and related warning)
Rahkonen Jukka
jukka.rahkonen at maanmittauslaitos.fi
Fri Dec 20 03:59:01 PST 2024
Hi,
All GeoTIFF creation options are documented in https://gdal.org/en/stable/drivers/raster/gtiff.html. There is no creation option "CREATE_RAT=YES". There is also no configuration option --config RAT_PATH. Either the name of your friend is AI or they are hallucinating.
The gdal_translate utility copies the RAT from the source image if it exists but gdal_translate cannot create RAT. If you work with GDAL the RAT must be written manually. Another option is to use QGIS with this plugin https://github.com/noaa-ocs-hydrography/qgis-raster-attribute-table-plugin
GDAL can read RAT for a GeoTIFF with two mechanisms. The native one is to use a PAM sidecar file (named xxxx.tif.aux.xml). The other one is to use an ESRI style .dbf file (named xxx.tif.vat.dbf), but support for the latter will come only with the next GDAL version 3.11 https://gdal.org/en/latest/drivers/raster/gtiff.html#raster-attribute-table. If you cannot wait for the next release you must use GDAL from the current master code base. Or use the PAM system.
The documentation of RAT is at GDAL: GDALRasterAttributeTable Class Reference<https://gdal.org/en/stable/doxygen/classGDALRasterAttributeTable.html>. I have not been experimenting much with RATs but I managed to make a simple RAT with a Python code from https://github.com/OSGeo/gdal/blob/e7b6c09d3b0de5886d9af9c4d0afb4eddafb0ef1/autotest/gcore/rat.py. The RAT defines columns VALUE and CLASS, and inserts one row into RAT with VALUE=123 and CLASS=Class1.
<PAMDataset>
<PAMRasterBand band="1">
<GDALRasterAttributeTable tableType="thematic">
<FieldDefn index="0">
<Name>VALUE</Name>
<Type>0</Type>
<Usage>5</Usage>
</FieldDefn>
<FieldDefn index="1">
<Name>CLASS</Name>
<Type>2</Type>
<Usage>2</Usage>
</FieldDefn>
<Row index="0">
<F>123</F>
<F>Class1</F>
</Row>
</GDALRasterAttributeTable>
</PAMRasterBand>
</PAMDataset>
For your ArcGIS online needs I think you no not need GDAL at all. Just create the .dbf file with your favorite program, name it as xxxx.tif.vat.dbf, and put it into the same place than the main file xxxx.tif. If you do not know what values appear in the TIFF file, then maybe gdalinfo can help “gdalinfo xxxx.tif -hist -json”. This advice may be wrong, I have not been experimenting with ArcGIS online a lot.
-Jukka Rahkonen-
Lähettäjä: gdal-dev <gdal-dev-bounces at lists.osgeo.org> Puolesta Giuseppe Triacchini via gdal-dev
Lähetetty: perjantai 20. joulukuuta 2024 2.39
Vastaanottaja: gdal-dev at lists.osgeo.org
Aihe: [gdal-dev] GEOTIFF with RAT - transformation unsuccessful (and related warning)
Dear GDAL-DEV Mailing List,
this is the first time with GDAL for me.
I would need to convert a GeoTIFF file already reclassified in Integer values into an analogous GeoTIFF with associated a RAT table.
I would need to use it with ESRI ArcGIS Online and apply unique-value style, which seems not feasible with normal raster layers (without RAT including unique categories).
I'm not sure that GeoTIFF can support a RAT for ArcGIS, but a friend suggested to follow the two next steps reported below to reach my objective, but it seems that the GTiff function does not support the creation of a RAT table for a TIFF.
Can someone more experienced than me confirm this?
Is there some alternative solution to create a raster dataset with RAT recognized as such by ESRI ArcGIS, in particular ArcGIS online?
Thanks in advance for your help
Best regards
Giuseppe
The procedure that was supposed to solve the issue:
After creating a DBF file with three essential columns VALUES CLASS and COUNT where VALUES refers to the distinct integers that are in the GeoTIFF, I used the following
GDA functions:
gdal_translate -of GTiff -co "CREATE_RAT=YES" InputFile.tif OutputFile_with_rat.tif
The raster is created but I get the following Warning 6: driver GTiff does not support creation option CREATE_RAT
Then I tried to associate anyway the DBF table to the new raster:
gdaladdo -r OutputFile_with_rat.tif --config RAT_PATH OutputFile_with_rat.dbf
This second command returns a positive feedback "Done"
0...10...20...30...40...50...60...70...80...90...100 - done.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20241220/6f532db2/attachment-0001.htm>
More information about the gdal-dev
mailing list