[gdal-dev] vrt guidance: 31 band classified raster

Even Rouault even.rouault at spatialys.com
Fri Oct 4 12:53:37 PDT 2019


On vendredi 4 octobre 2019 12:44:18 CEST mhw-at-yg wrote:
> > I don't see VRT cascading of any help here, from what I've understood of
> 
> your
> 
> > use case. I think you have no other choice than replicating <Category> and
> > <ColorTable> in all <VRTRasterBand>
> 
> Ok. Thanks for confirming my understanding.
> 
> Next question: It appears that <Category> <ColorTable> are order-of-index
> based. Meaning that: if "Evergreen" is first element in the category list it
> is matched to the first element in the color list. So there is no way in
> vrt to specify a lookup table of style "name == pixel_value" like the
> below?
> 
>   Pixel_Value       Category
>  ------------- ------------------
>             1   Evergreen Forest
>             2   Deciduous Forest
>           ...
>            14   Barren
>            15   Water
> 
> 
> I've worked around this by inserting an "n/a" category and 0,0,0 colour
> table as first line in each. Without that in qgis and arcmap everything is
> shifted by one and 'Deciduous' is assigned to pixel value 1 and 'Water' to
> 14.
> 

You could also potentially use a raster attribute table. See 
GDALRasterAttributeTable in https://gdal.org/drivers/raster/vrt.html
The documentation is a bit loose.
The values for Type and Usage match the enumerations at
https://github.com/OSGeo/gdal/blob/master/gdal/gcore/gdal.h#L1189

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list