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?

  • 6
    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. May 31, 2012 at 19:00
  • Removing the ReprojectImage order, my computer reprojects the image without the error. Mar 10, 2017 at 12:29

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.

  • I did not try the Option fix, but switching to calling gdalwarp through subprocess solved the issue with unmasked NoData.
    – j08lue
    Dec 1, 2016 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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