Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm having a lot of trouble with GDAL. Besides just the at times lacking documentation, there seems to be little support in Python. Anyways this is just a batch reproject script that goes thusly:

source_file = gdal.Open(filepath.encode("ascii"))
source_wkt = source_file.GetProjectionRef()
source_srs = osr.SpatialReference()

reproj_file = gdal.AutoCreateWarpedVRT(source_file, source_wkt, dest_wkt)
gdal.ReprojectImage(source_file, reproj_file, source_wkt, dest_wkt)
reproj_attributes = reproj_file.GetGeoTransform()

driver = gdal.GetDriverByName("GTiff")
dest_file = driver.CreateCopy(outputpath.encode("ascii"), reproj_file, 0)

The dest_srs and des_wkt part are not defined in this chunk of code but it's somewhere outside the loop (since it's only needs to be defined once). It seems to work once, I can get one nice looking tif out of it, then give me an 'ERROR 6 WriteBlock() not supported' and python crashes. They are all GeoTIFFs created in the same way with the same basic data (just different times).

Also due to the nature of the reprojection (from GCS to PCS), the AutoCreateWarpedVRT tends to create a lot of blank space, but gives it a value of 0, which is an issue since that could be a real data value. Is there someway to set the nodata value to -99 instead?

share|improve this question
I presume you have a reason for doing this in python, but just to make sure: you are aware that the gdalwarp utility's primary purpose is to reproject rasters? e.g. gdalwarp -t_srs '+proj=utm +zone=11 +datum=WGS84' raw_spot.tif utm11.tif. It's been around a long time, feature rich, well tested, and likely faster than a pure python approach. –  matt wilkie May 31 '12 at 19:00

1 Answer 1

Concerning AutoCreateWarpedVRT blank space.

Take a look at this gdal error ticket.

In particular it is stated there:

If I add this line into the rgbwarped.vrt generated in the second step everything is OK:

<Option name="UNIFIED_SRC_NODATA">YES</Option>

C++ applications can set this option directly. Applications using AutoCreateWarpedVRT from SWIG binding must add this line in to the text of the produced VRT manually.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.