A python 2.6.5 / ArcGIS 10 solution is preferred.

UPDATE: I found a tool to do this "Create Ortho Corrected Raster Dataset" but the python script for it gives errors when I try.

import arcpy
import glob
import os

path = os.getcwd()
filename = path+"\Stage2_19"
#for pathname, directories, filenames in os.walk(path):
#    for filename in filenames:
#        if filename.lower().endswith(".TIF"):
                                                   "CONSTANT_ELEVATION", "0")

print "Created: " + filename + ".jpg"

Gives the following errors.

Traceback (most recent call last): File "Q:\Software\GIS\ESRI\ArcGIS10\CustomScripts\temp\Georef-Rectified.py", line 16, in "CONSTANT_ELEVATION", "0") File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 7815, in CreateOrthoCorrectedRasterDataset raise e ExecuteError: ERROR 000425: Failed to create ortho-corrected raster dataset Failed to execute (CreateOrthoCorrectedRasterDataset).



I have georeferenced a few hundred survey plans using the Georeferencing toolbar in ArcGIS but did not Rectify the images (i.e create a new image) as I didn't want to create new files and take up more space. Now when I want to open them up in ERDAS or MapInfo they don't accept the prj created in the georeferencing process and require each using Rectify-->Save As

Can I use python to automate the process - open the georeferenced Tiff files and save them as Rectified Tiff or JPG files with the same name.

I noticed that there is an option for using gdal_translate but this gives me a syntax error and http://www.gdal.org/gdal_translate.html doesn't help to much (even when trying the example gdal_translate -of GTiff -co "TILED=YES" utm.tif utm_tiled.tif). Also not sure how it would handle the fact that the original file is only georeferenced and not rectified.

Please help...thanks,

  • Can't you Batch Rectify in ERDAS...? – ujjwalesri Jun 7 '11 at 11:18
  • Tried (in Imagine 2011 and ERMapper) and it doesn't accept the georeferencing (TFw) created in ESRI. It only accepts when I use the Georeferencing toolbar and RECTIFY the image (and not just Update Georeferencing). However MAPINFO 9.5 accepts the non-rectified image. The issue is there are hundreds of files to rectify and I would like to automate this process. Thanks. – GeorgeC Jun 9 '11 at 2:05
  • I've substantially added to the question. Any help would be appreciated. best. – GeorgeC Jul 6 '11 at 22:44

QGIS has a toolbar ("raster") with a set of tools that are GUIs of the gdal utilities. Among them "warp" and "translate". Almost all the tools can work in batch mode, selecting an entire directory instead of single files.

| improve this answer | |
  • Thanks mate...the issue is that it doesn't accept the Tfw created by Georeferencing without RECTIFY. That's one reason I was trying to work from with ArcMap/python. – GeorgeC Jun 9 '11 at 2:09

I had this same problem and needed to batch rectify TIFFs georeferenced in ArcGIS 10.0. First I tried to produce GeoTiffs with QGIS 2.2.0 (Raster, Conversion, Translate) which uses GDAL.

First problem: GDAL will create a GeoTIFF, but it does not have any projection. This appears to be a bug. The ESRI world file in ArcGIS has an extension of *.tfwx (if you have a tif file). GDAL expects the world file extension to be *.tfw, and not finding it, it goes ahead and produces a projectionless GeoTIFF. You can just rename the world file and this bug disappears. However, your resulting GeoTIFF is not rubber-sheeted/transformed as it is in ArcGIS 10.0.

So, a solution I developed was to batch rectify all the georeferenced tiffs in arcpy (python 2.6). I used arcpy.Warp_management. You can get all the parameters for this command from the *.tif.aux.xml file. (see code below). Next, I used qGIS to batch create the correct GeoTIFFs :)

import xml.etree.ElementTree as ET #for XML parsing

def rectify_warp(tif_path, rectified_path): # set all the paths dis_dir = os.path.dirname(tif_path) tif = os.path.basename(tif_path) out_raster = "r"+tif out_raster_path = os.path.join(rectified_path,out_raster) xml = tif+".aux.xml" xml_path = os.path.join(dis_dir, xml) if os.path.isfile(xml_path): # get xml tree tree = ET.parse(xml_path) root = tree.getroot() # get PolynomialOrder poly = 0
for elem in tree.getiterator(tag='PolynomialOrder'): poly = int(elem.text) if poly == 1: ''' 1st Order Polynomial (Affine)''' transformation_type = "POLYORDER1" resampling_type = "NEAREST" elif poly == 2: ''' 2nd Order Polynomial ''' transformation_type = "POLYORDER2" resampling_type = "BILINEAR"
elif poly == 3: ''' 3rd Order Polynomial ''' transformation_type = "POLYORDER3" resampling_type = "CUBIC" else: transformation_type = "NONE" resampling_type = "NONE"

    # get SourceGCPs
    gpc = []
    for elem in tree.getiterator(tag='SourceGCPs'):
        for chil in elem:
    #format for warp
    bog = []
    m = zip(gpc[0::2], gpc[1::2]) # see: http://stackoverflow.com/questions/2631189/python-every-other-element-idiom
    for i in m:
        bog.append("'%s %s'" % (i[0], i[1]))
    source_pnt = ";".join(bog)

    #get TargetGCPs
    tgpc = []
    for elem in tree.getiterator(tag='TargetGCPs'):
        for chil in elem:
    #format tgpc for warp
    bog = []
    m = zip(tgpc[0::2], tgpc[1::2])
    for i in m:
        bog.append("'%s %s'" % (i[0], i[1]))
    target_pnt = ";".join(bog)

    source_pnt = gpc_string
    target_pnt = tgpc_string
    print "Rectifying: %s" % tif
    arcpy.Warp_management(tif_path, source_pnt, target_pnt, out_raster_path, transformation_type, resampling_type)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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