Read, write, and manipulate Raster Attribute Tables (RATs) in Python — GeoTIFF, .aux.xml, and .vat.dbf backends.
No maintained PyPI package existed for RAT read/write as of May 2026. GDAL's raw Python bindings only cover the GeoTIFF backend with no pandas integration, no CLI, and no .vat.dbf support.
from raster_attr import RasterAttributeTable # Read — backend auto-detected (.vat.dbf > .aux.xml > tiff) rat = RasterAttributeTable.from_file("nlcd_2021.tif") df = rat.to_dataframe() print(df.head()) # Value Count ClassName Red Green Blue # 0 11 5200000 Open Water 70 107 159 # Add a column and save rat.add_column("Area_km2", "Real", "Generic", values=[v * 900 / 1e6 for v in df["Count"]]) rat.to_file("nlcd_2021.tif", backend="vat_dbf")
| Operation | Backend | Mean time |
|---|---|---|
| Write | vat_dbf | 129 ms |
| Read | vat_dbf | 292 ms |
| Write | aux_xml | 479 ms |
| Read | aux_xml | 261 ms |
| to_dataframe() | — | 5 ms |
| from_dataframe() | — | 2 ms |