I found a script to batch export geotiffs from data view and when hard coded it work well
mxd = arcpy.mapping.MapDocument("CURRENT")
res = 200 #resolution of tif
export = "S:\\6 - GIS\\For Randoms\\For Jeff\\Thunderchild Reserve\\Shapefiles\\Imagery" #folder
preFix = "image" #filename
widthcolumn = 3910 #width (number of columns)
heightrow = 1765 #height (number of rows)
df = arcpy.mapping.ListDataFrames(mxd)[0]
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
mxd.dataDrivenPages.currentPageID = pageNum
arcpy.AddMessage("Exporting Map " + str(pageNum) + " of " + str(mxd.dataDrivenPages.pageCount))
arcpy.mapping.ExportToTIFF(mxd, export + "\\" + preFix + str(pageNum) + ".tif",df,
df_export_width=widthcolumn,
df_export_height=heightrow,
resolution = res,
world_file=True,
tiff_compression="NONE",
geoTIFF_tags=True)
When I try to define my variables using the arcpy.GetParameterAsText() and set my export variable as folder in the tool box I return an error.
mxd = arcpy.mapping.MapDocument("CURRENT")
res = arcpy.GetParameterAsText(0) #resolution of tif
export = arcpy.GetParameterAsText(1) #folder save path
preFix = arcpy.GetParameterAsText(2) #filename
widthcolumn = arcpy.GetParameterAsText(3) #width (number of columns)
heightrow = arcpy.GetParameterAsText(4) #height (number of rows)
df = arcpy.mapping.ListDataFrames(mxd)[0]
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
mxd.dataDrivenPages.currentPageID = pageNum
arcpy.AddMessage("Resolution = " + res)
arcpy.AddMessage("Export Folder = " + export)
arcpy.AddMessage("Exporting Map " + str(pageNum) + " of " + str(mxd.dataDrivenPages.pageCount))
arcpy.mapping.ExportToTIFF(mxd, export + "\\" + preFix + str(pageNum) + ".tif",df,
df_export_width=widthcolumn,
df_export_height=heightrow,
resolution = res,
world_file=True,
tiff_compression="NONE",
geoTIFF_tags=True)
The error message that I get is:
*Executing: BatchExportGeotiffs 300 "S:\6 - GIS\For Randoms\For Jeff\Thunderchild Reserve\Shapefiles\Imagery" image 4888 2647
Start Time: Fri Mar 03 16:19:40 2017
Running script BatchExportGeotiffs...
Resolution = 300
Export Folder = S:\6 - GIS\For Randoms\For Jeff\Thunderchild Reserve\Shapefiles\Imagery
Exporting Map 1 of 4
Failed script BatchExportGeotiffs...
Traceback (most recent call last):
File "S:\6 - GIS\Resources\scripts\Python\BatchExportGeoTiffs.py", line 22, in <module>
geoTIFF_tags=True)
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\utils.py", line 182, in fn_
return fn(*args, **kw)
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\mapping.py", line 1391, in ExportToTIFF
layout.exportToTIFF(*args)
AttributeError: DataFrameObject: Error in parsing arguments for ExportToTIFF
Failed to execute (BatchExportGeotiffs).
Failed at Fri Mar 03 16:19:40 2017 (Elapsed Time: 0.04 seconds)*
Can anyone tell me where I'm going wrong?