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

Frank Warmerdam warmerdam at pobox.com
Thu Oct 7 11:05:27 EDT 2010


William Hudspeth wrote:
> Hello,
> 
> I am trying to copy a GeoTiff to an AAIGrid file using the Python
> osgeo-gdal CreateCopy() function. The metadata associated with the
> function indicates that one can output a Float32-formatted file, but I
> am having trouble figuring out exactly how the output format is
> specified in a call to the function....
> 
> What I have is:
> 
> src_filename='input.tif'
> src_ds=gdal.Open(src_filename)
> dst_ds_format="AAIGrid"
> dst_driver=gdal.GetDriverByName(dst_ds_format)
> dst_filename='output.asc'
> dst_ds_pm25=dst_driver.CreateCopy(dst_filename,src_ds,0,['Type=Float32'])
> 		    
> The way I have written the output data type argument obviously doesn't
> work... Can anyone help me with this?

Bill,

There is no way to make the AAIGRID CreateCopy() produce a floating
point output except to give it a floating point input.  Applications like
gdal_translate which supports an '-ot' output type flag accomplish this
by interposing a VRT dataset between the original CreateCopy that takes care
of the pixel type adaption.   But this is a hard approach to use in Python.

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