[gdal-dev] Percent stretch 16 to 8-bit geotiff conversion

David Shean dshean at uw.edu
Wed Sep 7 16:22:06 EDT 2011


Forgive me if this is not the proper forum (no gdal-users list?) or if this question has been answered in the past - I've been using GDAL for a while now, but just joined the mailing list and I'm relatively new to python.

I have large (>2GB uncompressed) UInt16 geotiffs that I need to convert to 8-bit geotiffs.  I'd like to use a percent range (e.g. 0.5-99.5%) to determine the new min/max for the linear stretch in gdal_translate.  I haven't found any simple way of doing this with the existing GDAL utilities, although it looks like gdalenhance was at least initially designed to do something along these lines. 

If there is no simple way to do this with existing tools, is there any sample code floating around that might help?  If not, I know it will be possible with the histogram/stats functions in gdal, numpy, or PIL - I just want to make sure that I'm not reinventing a slower, clunkier wheel.

Thanks.
-David

---
David Shean
Polar Science Center
Applied Physics Lab
University of Washington




More information about the gdal-dev mailing list