<div dir="ltr">Hi - I really appreciate all of your help so far. I am still looking into this though but will get back to you as soon as I have a solution. <div><br></div><div>Cheers - Gareth </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 18, 2015 at 6:17 PM, Joaquim Luis <span dir="ltr"><<a href="mailto:jluis@ualg.pt" target="_blank">jluis@ualg.pt</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>


<div><span class=""><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></span><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><span class="HOEnZb"><font color="#888888"><div><br></div><div>Joaquim</div></font></span><span class=""><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></span></div></blockquote></div><br></div>