[gdal-dev] python gdal gdal.ReprojectImage produces no data

Jachym Cepicky jachym.cepicky at gmail.com
Wed Jul 29 12:02:47 EDT 2009

Hi Frank (and others),

> Jachym,
> The problem is that your output file does not have a geotransform set,
> so ReprojectImage() does not realize the output file overlaps the
> area available from the input file.  You need to set the geotransform
> before calling ReprojectImage().  Setting the coordinate system is not
> critical since ReprojectImage() allows you to pass in an output coordinate
> system.
> Best regards,

Thanks, it helped. Just for the record:

from osgeo import gdal
from osgeo.gdalconst import *

# let's have georeferenced geotiff
inds = gdal.Open("elevationwgs.tif")

# create the driver
driver = gdal.GetDriverByName("GTiff")

# create new output file, note the datatype must be set
outds = driver.Create("outfile.tif",inds.RasterXSize, inds.RasterYSize,

# set geotransform parameter

# set the projection

# do the transformation - actually no transformation at all
# projections are no longer needed, since both datasets are projected
gdal.ReprojectImage(inds, outds)

# close
outds = None
inds = None

Jachym Cepicky
e-mail: jachym.cepicky gmail com
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/JachymCepicky.pgp
Key fingerprint: 0C6D 0EAE 76BD 506C F299  ED8A C8AB 74B8 08D4 E08F
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20090729/068e89c2/attachment.bin

More information about the gdal-dev mailing list