<!DOCTYPE html><html><head>
<style type="text/css">body { font-family:'Times New Roman'; font-size:13px}</style>
</head>
<body><blockquote style="margin: 0 0 0.80ex; border-left: #0000FF 2px solid; padding-left: 1ex"><div dir="ltr"><p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">My objective is to create a hillshaded
color-relief image of a DEM using commandline/programmatic means only, so the
process can be automated and combined within an existing GMT/GDAL workflow.</span></p></div></blockquote><div><br></div><div>If your workflow includes GMT that you have a reach panoply of methods to do shade illuminations. See man pages of grdgradient and grdhisteq.</div><div><br></div><div>Joaquim</div><div><br></div><blockquote style="margin: 0 0 0.80ex; border-left: #0000FF 2px solid; padding-left: 1ex"><div dir="ltr">

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black"> </span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">Currently, I can generate both hillshaded and
color-relief rasters using gdaldem and combine them with Mapnik (using opacity)
to generate a my final rendered image. However, this process will use the
min-max values in the grayscale hillshaded image.</span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black"> </span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">However, I can achieve an improved or sharper
hillshaded image when I manually use QGIS to further process the hillshaded
image by:</span></p>

<p><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">1. Adding the hillshaded raster to QGIS, which applies by default the 'Cumulative
count cut 2% - 98%' style.</span></p><p><span style="color:black;font-family:Arial,sans-serif;font-size:10pt">2. Then export the hillshaded raster (with the cumulative count style applied) as
a “Rendered Image”.</span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black"> </span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">I have annotated a screenshot here <a href="https://www.dropbox.com/s/ftzk7j2bmznuvjn/raster_band_rendering.png?dl=0" target="_blank"><span style="color:black">https://www.dropbox.com/s/ftzk7j2bmznuvjn/raster_band_rendering.png?dl=0</span></a>
hopefully illustrating the</span></p>

<p><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">1.    Improved hillshaded raster output from QGIS ('Cumulative count cut) compared
with, </span></p>

<p><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">2.    gdal+mapnik output (using min-max) </span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black"> </span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">So, is there an approach using gdal (or
similar command-line tool/app) to achieve the “improved” hillshaded raster
without the “manual” QGIS step?</span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black"> </span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">As I see it, my options are:</span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">1. Use gdalinfo with the “-hist” option to
export the histogram of the hillshaded raster. I guess then I could maybe calculate
the 2% and 98% percentile(?) values and then manipulate the raster values using
gdal_calc.py or something else.  However, I’m no statistician, so hoped
there would be an out of the box solution?!</span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">2. Maybe, I could use the python api for QGIS
to import the hillshade, render, style and export back out. I’m sure this is
possible, but would require an additional python script.</span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">3. Use another library or framework to
achieve either of the above. I’ve researched python’s numpy library, which
maybe I could do the percentage calculation directly on the raster. Again,
potentially tricky learning curve there…</span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black"> </span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">Any help or advice would greatly appreciated.
If any help, the data I’m using is here <a href="https://www.dropbox.com/s/v0peaa3rzaqbhen/raster_band_rendering.zip?dl=0" target="_blank"><span style="color:black">https://www.dropbox.com/s/v0peaa3rzaqbhen/raster_band_rendering.zip?dl=0</span></a></span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black"> </span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">Cheers</span></p>

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black"><br>
Gareth</span></p></div>
</blockquote><br><br><br></body></html>