Let's say I have 1 band raster images with Gray Color Interpretation and I want to change their color based on their data values. Data values -1, will be Blue, -0.5 will be Light Blue, 0 will be Yellow, 0.5 will be Orange and 1 will be Red. If the data values are <-3000, I want to have that colored Black and if the data values are >3.402, that should be colored White . Will that be possible in gdal? And process that in batch?
Answer
c1 to c4 in the vrt file are the RGBA values you see in a 4-channel RGBA tif file. Every row corresponds to an integer palette value in the source file.
EDIT
gdaldem
seems to be the right tool for your task:
- Take a raster of your choice (like SRTM as an example)
- Create the following text file named
col.txt
:
0 black
100 blue
200 yellow
300 orange
400 red
500 white
- On command line, run
gdaldem color-relief N51E007.hgt col.txt out.tif
and the result will look like this:
I have added white dashed contour lines to show that the colours get interpolated.
Instead of colour names, you can use RGB values as well, see http://www.gdal.org/gdaldem.html#gdaldem_color_relief for details:
The supported list is : white, black, red, green, blue, yellow, magenta, cyan, aqua, grey/gray, orange, brown, purple/violet and indigo
You can create a vrt file as output too and look into that on how the interpolating is done with
keys:
gdaldem color-relief -of VRT N51E007.hgt col.txt out.vrt
...
Red
N51E007.hgt
1
0:0,100:0,200:0,300:255,400:255,500:255
update
To apply different transparencies, I got around with this batch:
gdaldem color-relief -of GTiff N51E006.hgt color.txt output6.tif -alpha
gdaldem color-relief -of GTiff N51E007.hgt color.txt output7.tif -alpha
and this color.txt:
0. 255 255 255 0
50. 255 0 0 50
100. 0 255 0 100
150. 0 0 255 150
with elevation in meters, and RGBA values between 0 and 255.
No comments:
Post a Comment