3

For some unknow reason, my average of 3 hillshades is very dark :

gdaldem hillshade input.tif hillshades_C.tmp.tif -s 111120 -z 5 -az 315 -alt 60 -compute_edges
gdaldem hillshade input.tif hillshades_B.tmp.tif -s 111120 -z 5 -az 355 -alt 60 -compute_edges
gdaldem hillshade input.tif hillshades_A.tmp.tif -s 111120 -z 5 -az 275 -alt 60 -compute_edges
gdal_calc.py -A hillshades_A.tmp.tif  -B hillshades_B.tmp.tif -C hillshades_C.tmp.tif --outfile=./hillshades.tmp.tif --calc="(A+B+C)/3"

enter image description here

I did tried --calc="(A+B+C)", it get lighter, but still too dark and not as expected.

Hugolpz
  • 2,653
  • 3
  • 26
  • 51

1 Answers1

4

For my case (hillshade and my computer), I had to use --calc="(A/3+B/3+C/3)" to get a correct average results.

(A+B+C)/3 fails because gdal_calc limit the equation to a [0-255] range. (A+B+C)/3 will first calculate A+B+C modulo 256, then divide this value (in range [0-255]) by 3, giving a low value and dark output.

For more on gdal_calc operators, see How does gdal_calc numpy operators work?

Hugolpz
  • 2,653
  • 3
  • 26
  • 51