[gdal-dev] gdal_translate -scale

jratike80 jukka.rahkonen at maanmittauslaitos.fi
Mon Dec 14 04:18:06 PST 2020


Hi,

If your output is 8 bit you can just use -scale without min/max values.
>From https://gdal.org/programs/gdal_translate.html:

"Rescale the input pixels values from the range src_min to src_max to the
range dst_min to dst_max. If omitted the output range is 0 to 255. If
omitted the input range is automatically computed from the source data."

If your data is higher than 8 bit and you want to keep it so you are out of
luck with gdal_translate because it first omits the output range and sets it
into 0-255 before it can omit the input range and compute the range
automatically.

The current behavior is not optimal for certain use cases
(https://gis.stackexchange.com/questions/294129/min-max-stretch-using-gdal-translate-in-a-batch).
Some programmer learning GDAL could take this as a challenge and formulate
how to improve the automatic scaling support so that it would not break too
much. As a first aid a Python script for automatic min/max scaling would be
nice, and why not with an option to utilize the histogram and use for
example +/- 98% of the histogram. Or mean +/- (2 x RMS).

-Jukka Rahkonen-



jesus.moran wrote
> Hello GDAL team and thank you for welcome me.
> 
>  
> 
> I have an issue with the gdal_translate command. I would like to use the
> “STATISTICS_MIN” and “STATISTICS_MAX” metadata key values in the -scale
> parameter of the program, so I don’t need to specify it manually every
> time
> I want to scale the output. Is there any way to do this?
> 
>  
> 
> Thanks a lot in advance!
> 
>  
> 
> 
>  <http://www.solute.es/> 
> 
> 
> Jesús Maria Morán Rosado
> Project Engineer
> 
> Av. Cerro del Águila, 3, 28703 S.S. de los Reyes, Madrid
> 
> CONFIDENTIALITY: This e-mail and any attachments are confidential and may
> be
> privileged. If you are not a named recipient, please notify the sender
> immediately and do not disclose the contents to another person, use it for
> any purpose or store or copy the information in any medium.
> 
>  
> 
> 
> _______________________________________________
> gdal-dev mailing list

> gdal-dev at .osgeo

> https://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
> 
> image001.gif (2K)
> <http://osgeo-org.1560.x6.nabble.com/attachment/5452429/0/image001.gif>





--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html


More information about the gdal-dev mailing list