<div dir="ltr">Gareth,<div>   Frank implemented a method to merge a hillshade and color-mapped image in GDAL/python (called hsv_merge.py). This code could be changed to meet your needs. Otherwise you might be able to stretch the hillshade using the scale parameter in gdal_translate prior to using hsv_merge.py.</div><div><br></div><div><a href="https://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/" target="_blank">https://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/</a><br></div><div><br></div><div>example workflow: </div><div><a href="http://linfiniti.com/2010/12/a-workflow-for-creating-beautiful-relief-shaded-dems-using-gdal/" target="_blank">http://linfiniti.com/2010/12/a-workflow-for-creating-beautiful-relief-shaded-dems-using-gdal/</a><br></div><div><br></div><div>There many different methods to blend these two files together. If you write an update to hsv_merge.py it would be good to hear about. </div><div><br></div><div>For a C++ (faster) implementation of hsv_merge, NASA Ames have released binaries (and code) within their<span style="color:rgb(0,0,0);font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:15.6000003814697px"> </span><span style="color:rgb(0,0,0);font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:15.6000003814697px">Stereo Pipeline (ASP) package. </span><span style="color:rgb(0,0,0);font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:15.6000003814697px"> </span><font color="#000000" face="Arial, Helvetica, sans-serif"><span style="font-size:12px;line-height:15.5999994277954px"><a href="http://ti.arc.nasa.gov/tech/asr/intelligent-robotics/ngt/stereo/" target="_blank">http://ti.arc.nasa.gov/tech/asr/intelligent-robotics/ngt/stereo/</a></span></font></div><div><font color="#000000" face="Arial, Helvetica, sans-serif"><span style="font-size:12px;line-height:15.5999994277954px"><br></span></font></div><div><font color="#000000" face="Arial, Helvetica, sans-serif"><span style="font-size:12px;line-height:15.5999994277954px">Good luck,</span></font></div><div><font color="#000000" face="Arial, Helvetica, sans-serif"><span style="font-size:12px;line-height:15.5999994277954px">Trent</span></font></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 18, 2015 at 8:41 AM, Gareth Grewcock <span dir="ltr"><<a href="mailto:garethgrewcock@gmail.com" target="_blank">garethgrewcock@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black">Hi - firstly, apologies if the gdal-dev
mailing is not the appropriate mailing list, please advise a more
suitable place to post if so.</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">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>

<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><span><font color="#888888">

<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:black"><br>
Gareth</span></p></font></span></div>
<br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br></div></div>