Tuesday, 17 May 2016

python - Automate creating Rectified files from georeferenced images



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"):
arcpy.GetMessages()
arcpy.CreateOrthoCorrectedRasterDataset_management(filename+".TIF",\
filename+".jpg",\
"CONSTANT_ELEVATION", "0")

arcpy.GetMessages()
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).



>






ORIGINAL:


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,




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...