I have a binary ArcGRID raster (AIG/Arc/Info Binary Grid) with an attribute table. I would like to get only this attribute table but gdalinfo
outputs also projection information and bounds and then wanted GDALRasterAttributeTable XML part:
$ gdalinfo us_120fbfm13 -nogcp -nomd -noct filename
Driver: AIG/Arc/Info Binary Grid
...
Coordinate System is:
PROJCS["unnamed",
...
Center ( 1540680.000, 1553400.000) ( 78d42'42.88"W, 35d46' 8.50"N)
Band 1 Block=256x4 Type=Byte, ColorInterp=Undefined
Min=1.000 Max=99.000
NoData Value=255
<GDALRasterAttributeTable>
...
How to show only raster attribut table using GDAL command line tools gdalinfo
or perhaps gdal_translate
?
Additional question which might be separate but might be also answered together with this is whether there is a possibility to get the attribute table in format such as CSV and not XML.
I'm on Linux, so I can actually do something like:
gdalinfo us_120fbfm13 -nogcp -nomd -noct -nofl | grep "<.*>"
but I would rather use some more general and possibly cross-platform solution.
Best Answer
Unless you use os/shell specific operations i.e.
grep
etc... there's no way that I know of to do this from the command line withgdalinfo
.A python alternative is to use the GetDefaultRAT() method and output to XML (which is what gdalinfo does):
and here's a function to write out a CSV file.