Batch export to GeoTIFF in dataview

1988
4
11-10-2016 01:31 PM
PeterVersteeg
Occasional Contributor II

Hallo,

I am looking for a script that can export to tiff in data view because I need them georeferenced.

I found this old question: Batch export to GeoTIFFs for set polygon features in data frame?

It looks like the thing I need but the script is not working. When i run it i get:

syntaxerror: EOL while scanning string literal

i am using arcgis for desktop 10.3

hope sameone can help me

import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
ar = df.extent.height / df.extent.width

for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
      mxd.dataDrivenPages.currentPageID = pageNum
      print "Exporting page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID),       str(mxd.dataDrivenPages.pageCount))
arcpy.mapping.ExportToTIFF(mxd,r"D:\ImageTemp\" + str(pageNum) + ".tif",df,1024,1024*ar,48,True)

del mxd

Tags (2)
0 Kudos
4 Replies
PeterVersteeg
Occasional Contributor II

I got the script working but it is still making tiffs from layout view and not dataview (geotiff). anyone know how i can make this script to export from dataview?

import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")
res = arcpy.GetParameterAsText(0)
export = arcpy.GetParameterAsText(1)
preFix = arcpy.GetParameterAsText(2)
ar = df.extent.height / df.extent.width

for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
         mxd.dataDrivenPages.currentPageID = pageNum

         arcpy.AddMessage("Exporting Map " + str(pageNum) + " of " + str(mxd.dataDrivenPages.pageCount))
         pageName = mxd.dataDrivenPages.pageRow.MapName
         arcpy.mapping.ExportToPDF(mxd, export + "\\" + preFix + pageName + ".pdf", resolution = res,
                        df_export_width=1600,
                        df_export_height=1200*ar,
                        geoTIFF_tags=True)
del mxd

0 Kudos
LukeWebb
Occasional Contributor III

You are exporting a "Map", it sounds like you want to export "Data"

As you dont provide a "Dataframe" parameter in this line of code, you will get that.

 arcpy.mapping.ExportToPDF(mxd, export + "\\" + preFix + pageName + ".pdf", resolution = res,
                        df_export_width=1600,
                        df_export_height=1200*ar,
                        geoTIFF_tags=True)

From help:

ExportToTIFF (map_document, out_tiff, {data_frame}, {df_export_width}, {df_export_height}, {resolution}, {world_file}, {color_mode}, {tiff_compression}, {geoTIFF_tags})
data_frame

A variable that references a DataFrame object. Use the string/constant "PAGE_LAYOUT" to export the map document's page layout instead of an individual data frame.

(The default value is PAGE_LAYOUT)

PeterVersteeg
Occasional Contributor II

your right sorry did not see your mail.

0 Kudos
PeterVersteeg
Occasional Contributor II

With the help from Glenn Heeres from Esri The Netherlands the script works now. I did not set the DF. now the script is:

mxd = arcpy.mapping.MapDocument("CURRENT")
res = arcpy.GetParameterAsText(0)
export = arcpy.GetParameterAsText(1)
preFix = arcpy.GetParameterAsText(2)
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))
      pageName = mxd.dataDrivenPages.pageRow.MapName
      arcpy.mapping.ExportToTIFF(mxd, export + "\\" + preFix + pageName + ".tif",df,
                     df_export_width=10369,
                     df_export_height=6375,

                     resolution = res,
                     world_file=True,
                     tiff_compression="NONE",
                     geoTIFF_tags=True)
del mxd

If i look at my geotiff ino the dpi is stil at 96 but i compared the geotiff with one made bij export map (in that tiff the dpi is what i set it to by (600) and the are the same. the workflow for this script is:

set your window in arcgis then look at export map set the dpi you want and you wil get the with and hight. set the width and hight in the script and all works wel.

greetings Peter

0 Kudos