[gdal-dev] storing height information in a .tif rather the grayscale in the tif relying on another file

Frank Warmerdam warmerdam at pobox.com
Tue Feb 23 08:40:49 EST 2010


anotherObject wrote:
> I have successfully been using gdal_translate to convert some tifs. Viewing
> my resulting 8 byte tifs through a GIS viewer, the color ramp is perfect.
> However I converted these to 8 byte so i could further work with them in
> photoshop. 
> 
> When I open one of my 8 byte .tifs in photoshop, the DEM looks different
> (looks like some type of stretch, cant be sure, but it looks like standard
> deviation. 
> 
> I gather this means that when gdal is saving the tif, the actual colors it
> stores in the tif are not the elevation values themselves, but instead rely
> on a histogram calculation (from an outside file) to correct for showing the
> actual elevations.I have tried correcting for this in photoshop, but the
> histogram tools are not nearly as sophisticated enough for any precise
> manipulation. 
>

Ytrapaet,

If you had a 16bit DEM with no color information (such as a normal DTED
for instance) the following command would convert to 8bit by linear scaling
of the min/max to 0-255 without applying any color table.  The implicit
color interpretation of the result is greyscale.

   gdal_translate -scale -ot Byte in.dt1 out.tif

I'm not positive what you did, or what you started with since you didn't
explain.

 > I am still a newbie in gdal.  How can i save an 8byte tif so that the actual
 > .tif grayscale colors are not stretched at all? (does not rely on another
 > file to correct for this?). Or conversely, how can I convert how a .tif is
 > stretched? Is this going outside the realm of gdal_translate?

Note that raw DEM data has no inherent coloring so it doesn't really mean
anything to say "so that the actual .tif grayscale colors are not stretched
at all" in this context.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list