[gdal-dev] Hillshade | Raster Band Rendering

Hare, Trent thare at usgs.gov
Wed Mar 18 09:45:30 PDT 2015


Gareth,
   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.

https://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/

example workflow:
http://linfiniti.com/2010/12/a-workflow-for-creating-beautiful-relief-shaded-dems-using-gdal/

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.

For a C++ (faster) implementation of hsv_merge, NASA Ames have released
binaries (and code) within their Stereo Pipeline (ASP) package.
http://ti.arc.nasa.gov/tech/asr/intelligent-robotics/ngt/stereo/

Good luck,
Trent

On Wed, Mar 18, 2015 at 8:41 AM, Gareth Grewcock <garethgrewcock at gmail.com>
wrote:

> Hi - firstly, apologies if the gdal-dev mailing is not the appropriate
> mailing list, please advise a more suitable place to post if so.
>
>
>
> 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.
>
>
>
> 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.
>
>
>
> However, I can achieve an improved or sharper hillshaded image when I
> manually use QGIS to further process the hillshaded image by:
>
> 1. Adding the hillshaded raster to QGIS, which applies by default the
> 'Cumulative count cut 2% - 98%' style.
>
> 2. Then export the hillshaded raster (with the cumulative count style
> applied) as a “Rendered Image”.
>
>
>
> I have annotated a screenshot here
> https://www.dropbox.com/s/ftzk7j2bmznuvjn/raster_band_rendering.png?dl=0
> hopefully illustrating the
>
> 1.    Improved hillshaded raster output from QGIS ('Cumulative count cut)
> compared with,
>
> 2.    gdal+mapnik output (using min-max)
>
>
>
> So, is there an approach using gdal (or similar command-line tool/app) to
> achieve the “improved” hillshaded raster without the “manual” QGIS step?
>
>
>
> As I see it, my options are:
>
> 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?!
>
> 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.
>
> 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…
>
>
>
> Any help or advice would greatly appreciated. If any help, the data I’m
> using is here
> https://www.dropbox.com/s/v0peaa3rzaqbhen/raster_band_rendering.zip?dl=0
>
>
>
> Cheers
>
>
> Gareth
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20150318/fb0aa880/attachment-0001.html>


More information about the gdal-dev mailing list