I am trying to convert a geoTIFF to a kml with gdal_translate -of KMLSUPEROVERLAY, however I don't know how to do so with a color gradient.
My geotiff is an 8bit raster with valid values ranging from 0-100. I'd like a simple output where 0-10 is gray, and 11-100 has a one-color gradient from light to dark (say, purple). This could be in classes of 11-20, 21-30, etc. or whatever, as long as it goes from light to dark.
Is this possible?
Is there a way to supply a color table with values and their corresponding RGB values? I see some options on gdal_translate but don't know where to start.
Best Answer
Found a solution to my problem:
gdaldem color-relief converts a grayscale tiff to a multiband RGB(A) tiff
'-alpha' says my color table has an alpha band (which controls transparency)
'-co format=png' outputs the tiles in .png instead of the default .jpg, because the latter does not support transparency (How can I create a kml file from a geotiff with alpha layer)
'-of KMLSUPEROVERLAY' says my output type is kml/kmz. I specified a .kmz extension because it puts all the tile layers/kmls into one file that GoogleEarth can read
Lastly, color.txt looks like this:
Values of 0 and NoData are fully transparent, 1-20 is gray, and 20-100 have a light-dark purple gradient with classes of 10.