[gdal-dev] Problems using gdal python binding 'createcopy' function

Frank Warmerdam warmerdam at pobox.com
Thu Oct 7 12:30:32 EDT 2010


William Hudspeth wrote:
> Hi Frank,
> 
> Thanks for responding. I have tried the following,
> 
> 
> gdal_translate -ot Float32 -of AAIGrid src.tif dst.asc
> 
> 
> Only to get an AAIGrid in Int16 format....??

Bill,

I see that by default floating point values in the AAIGRID CreateCopy
code are written as "%6.20g" which just produces an integer representation
if the values are integers.  I tried this which did produce floating point
output values since the original pixels were rescaled in the 0.0 to 1.0 range.

gdal_translate utm.tif out.grd -of AAIGRID -ot Float32 -scale 0 255 0 1

(the exceptions were still the integer values of 0 and 1)

I see you can manually control the formatting with the DECIMAL_PRECISION
creation option.

eg.

gdal_translate utm.tif out.grd -of AAIGRID -ot Float32 -co DECIMAL_PRECISION=3

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