Automate creating Rectified files from georeferenced images

3054
6
07-12-2011 10:56 PM
George_ChandeepCorea
New Contributor III
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 tfw/xml created in the georeferencing process and require a file created using - Georeferencing toolbar-->Rectify-->Save As

I found a tool that should do this -"Create Ortho Corrected Raster Dataset" but the tool and python script for it gives errors when I try. When I try it from within ArcMap it just hangs for hours with no processing active.

import arcpy, glob, os
    
path = os.getcwd()
files = glob.glob('*.tif')
for file in files:
    fileTIF=path+"\\"+file
    fileJPG=path+"\\"+file+".jp2"
    print fileTIF, fileJPG
    arcpy.CreateOrthoCorrectedRasterDataset_management(fileTIF,fileJPG,"CONSTANT_ELEVATION", "1")
    arcpy.GetMessages()
    print arcpy.GetMessages()
    print "Created: " + fileJPG


>>>
C:\Python26\script_tests\rectify\Stage1_01a.TIF C:\Python26\script_tests\rectify\Stage1_01a.TIF.jp2
Traceback (most recent call last):
  File "C:\Python26\script_tests\rectify\rectify.py", line 12, in <module>
    arcpy.CreateOrthoCorrectedRasterDataset_management(fileTIF,fileJPG,"CONSTANT_ELEVATION", "1")
  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).
0 Kudos
6 Replies
RobertBerger
New Contributor III
Greetings,

In order to rectify your images as a new output you should be able to do a simple copy raster (SaveAs) to a new dataset. That should write a new dataset with the georeferencing information.
Orthorectification is the process to remove elevation displacement from the image by using an elevation dataset with your imagery. It doesn't seem that this is what you're looking for.
Hope this helps.

Robert
George_ChandeepCorea
New Contributor III
Thanks mate...I tried it but when using the tool and the python, the files don't seem to retain proper georeferencing...I also tried Data-->Export Data and this correctly projects the file but also creates a black (no data) boundary around the image. The only thing that works is Georeferencing Toolbar-->Rectify--> using NoData value as 0. The issue with this is that I have to do each file of hundreds by hand as there doesn't seem to be python for this...

In the python I replaced
#arcpy.CreateOrthoCorrectedRasterDataset_management(fileTIF,fileJPG,"CONSTANT_ELEVATION", "1")
with
arcpy.CopyRaster_management(fileTIF,fileJPG)
0 Kudos
RobertBerger
New Contributor III
Greetings,

If you did an "update georeferencing" then the spatial reference should be retained in the image. The copy raster tool also has the nodata parameter that you can set to 0 to avoid black borders. Generally that should work if your input already has the spatial reference.

Robert
0 Kudos
George_ChandeepCorea
New Contributor III
Thanks Robert. The issue is that I need to batch process these -ideally with python and there is no way (I could find) apart from the 2 tools I mentioned in my original post and those have the issues mentioned.

I couldn't find the no data param in the python of the copy raster tool.

best,
0 Kudos
George_ChandeepCorea
New Contributor III
Figured it/found how to use the no data value but MapInfo/ERDAS still don't open the files in the right georeferenced space. The only option that works is the manual process. Would it be possible to use Model builder to automate the creation rather than python?
0 Kudos
PavanYadav
Esri Contributor
Hi,
You can run the Copy Raster tool in a batch mode (in the ArcToolbox > navigate to the Copy Raster tool > Right click the tool and select Batch). Or, you can create a model (iterator) or script (use RasterList).

ListRasters returns a Python list of the rasters in the workspace, limited by name and raster type.

Model Iterator.

Thanks
0 Kudos