Python GIS MIT

raster-attr

Read, write, and manipulate Raster Attribute Tables (RATs) in Python — GeoTIFF, .aux.xml, and .vat.dbf backends.

raster-attribute-table gdal land-cover remote-sensing geospatial

Why it exists

rasterio#3185 — "Add reading and writing of raster attribute tables (RAT)" — open since 2024
natcap/invest#2333 — "Reports: Display Raster Attribute Tables for LULC maps"
SE#48264, SE#55292, SE#192356, SE#500270 — unanswered RAT questions on GIS Stack Exchange

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.

Quickstart

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")

Benchmark (50 000 classes)

OperationBackendMean time
Writevat_dbf129 ms
Readvat_dbf292 ms
Writeaux_xml479 ms
Readaux_xml261 ms
to_dataframe()5 ms
from_dataframe()2 ms