<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Helvetica;
panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
p.ydp1dec658cyiv4550036678ydp55f28544msonormal, li.ydp1dec658cyiv4550036678ydp55f28544msonormal, div.ydp1dec658cyiv4550036678ydp55f28544msonormal
{mso-style-name:ydp1dec658cyiv4550036678ydp55f28544msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.Shkpostityyli19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 2.0cm 70.85pt 2.0cm;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FI" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">All GeoTIFF creation options are documented in
<a href="https://gdal.org/en/stable/drivers/raster/gtiff.html">https://gdal.org/en/stable/drivers/raster/gtiff.html</a>. There is no creation option "CREATE_RAT=YES". There is also no configuration option
</span><span lang="EN-US" style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">--config RAT_PATH. Either the name of your friend is AI or they are hallucinating.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">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 <a href="https://github.com/noaa-ocs-hydrography/qgis-raster-attribute-table-plugin">
https://github.com/noaa-ocs-hydrography/qgis-raster-attribute-table-plugin</a><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">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 <a href="https://gdal.org/en/latest/drivers/raster/gtiff.html#raster-attribute-table">
https://gdal.org/en/latest/drivers/raster/gtiff.html#raster-attribute-table</a>. If you cannot wait for the next release you must use GDAL from the current master code base. Or use the PAM system.<br>
<br>
The documentation of RAT is at </span><a href="https://gdal.org/en/stable/doxygen/classGDALRasterAttributeTable.html"><span lang="EN-US">GDAL: GDALRasterAttributeTable Class Reference</span></a><span lang="EN-US">. I have not been experimenting much with RATs
but I managed to make a simple RAT with a Python code from <a href="https://github.com/OSGeo/gdal/blob/e7b6c09d3b0de5886d9af9c4d0afb4eddafb0ef1/autotest/gcore/rat.py">
https://github.com/OSGeo/gdal/blob/e7b6c09d3b0de5886d9af9c4d0afb4eddafb0ef1/autotest/gcore/rat.py</a>. The RAT defines columns VALUE and CLASS, and inserts one row into RAT with VALUE=123 and CLASS=Class1.</span><span lang="EN-US" style="mso-fareast-language:EN-US"><br>
<br>
<PAMDataset><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> <PAMRasterBand band="1"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> <GDALRasterAttributeTable tableType="thematic"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> <FieldDefn index="0"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> <Name>VALUE</Name><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> <Type>0</Type><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> <Usage>5</Usage><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> </FieldDefn><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> <FieldDefn index="1"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> <Name>CLASS</Name><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> <Type>2</Type><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> <Usage>2</Usage><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> </FieldDefn><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> <Row index="0"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> <F>123</F><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> <F>Class1</F><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> </Row><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> </GDALRasterAttributeTable><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> </PAMRasterBand><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"></PAMDataset><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">-Jukka Rahkonen-<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>Lähettäjä:</b> gdal-dev <gdal-dev-bounces@lists.osgeo.org>
<b>Puolesta </b>Giuseppe Triacchini via gdal-dev<br>
<b>Lähetetty:</b> perjantai 20. joulukuuta 2024 2.39<br>
<b>Vastaanottaja:</b> gdal-dev@lists.osgeo.org<br>
<b>Aihe:</b> [gdal-dev] GEOTIFF with RAT - transformation unsuccessful (and related warning)<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Dear GDAL-DEV Mailing List, </span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif"><o:p></o:p></span></p>
</div>
</div>
<div id="ydp1dec658cyahoo_quoted_5266307804">
<div>
<div>
<div id="ydp1dec658cyiv4550036678">
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">this is the first time with GDAL for me.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">I would need to convert a GeoTIFF file already reclassified in Integer values into an analogous GeoTIFF with associated a RAT table.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">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).<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">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. <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Can someone more experienced than me confirm this?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Is there some alternative solution to create a raster dataset with RAT recognized as such by ESRI ArcGIS, in particular ArcGIS online?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Thanks in advance for your help<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Best regards<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Giuseppe<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><b><u><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">The procedure that was supposed to solve the issue:</span></u></b><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">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<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">GDA functions:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">gdal_translate -of GTiff -co "CREATE_RAT=YES" InputFile.tif OutputFile_with_rat.tif<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">The raster is created but I get the following </span><b><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:black">Warning 6: driver GTiff
does not support creation option CREATE_RAT</span></b><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Then I tried to associate anyway the DBF table to the new raster: <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">gdaladdo -r
</span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:black">OutputFile_with_rat.</span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">tif --config RAT_PATH
</span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:black">OutputFile_with_rat</span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">.dbf<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">This second command returns a positive feedback "Done"<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">0...10...20...30...40...50...60...70...80...90...100 - done.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="ydp1dec658cyiv4550036678ydp55f28544msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>