Skip to main content


I've been struggling with adding a colormap to a landcover raster. There is https://gdal.org/programs/gdalattachpct.html but apparently it isn't included in the GDAL that comes with QGIS or osgeo4win.

I finally tried using #rasterio, and and am happy to report that it works like a charm! https://rasterio.readthedocs.io/en/stable/topics/color.html#writing-colormaps
in reply to Keith Jenkins

I guess GRASS would be the other option, I faintly remember a rgb2pct tool or something similar in the qgis toolbox.
in reply to Raúl Nanclares 🍜

@rnanclares rgb2pct is a GDAL tool available in QGIS that does a great job finding the unique color values and creating a raster of classes from that. One problem I ran into, though, was that I needed to do this will different rasters for different cities, and the rgb2pct classes ended up in different arbitrary orders for different cities (like water would be 2 in one city, but 7 in another)

This website uses cookies to recognize revisiting and logged in users. You accept the usage of these cookies by continue browsing this website.