1

I have two data frames ("Final" and "OverviewMap1") on one Layout View and I can't export them as a whole in one GeoTIFF. What is wrong with the following script:

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Users\gnowak\Desktop\Fredropol_FINALv3.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Final", "OverviewMap1")[0]
arcpy.mapping.ExportToTIFF(mxd, r"C:\Users\gnowak\Desktop\Fredropol.tif", df,
                           df_export_width=1346,
                           df_export_height=1003,
                           geoTIFF_tags=True)
del mxd

Edit:

The following script works but I want to export GeoTIFF layout and want to setup resolution, width and height of tif.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
arcpy.mapping.ExportToPDF(mxd, r"C:\Project\Output\Project.pdf")
del mxd
1

The first question is about not being able to export the layout view as whole. This is because

df = arcpy.mapping.ListDataFrames(mxd, "Final", "OverviewMap1")[0]   

is an individual dataframe (a DataFrame object). Instead you should use the data_frame parameter as "PAGE_LAYOUT" (default) to export the map document's page layout.

import arcpy

mxd = arcpy.mapping.MapDocument(r"C:\Users\gnowak\Desktop\Fredropol_FINALv3.mxd")
arcpy.mapping.ExportToTIFF(mxd, r"C:\Users\gnowak\Desktop\Fredropol.tif", data_frame = "PAGE_LAYOUT", geoTIFF_tags=True)

del mxd

you can also omit data_frame = "PAGE_LAYOUT" in the above code.

The second question is that you want to control width, height and resolution in the exported file.

It is possible to use the parameter resolution:

arcpy.mapping.ExportToTIFF(mxd, r"C:\Users\gnowak\Desktop\Fredropol.tif", resolution = 100, geoTIFF_tags=True)

but width and height needs to be pre-authored. The ExportToTIFF documentation says:

df_export_width: ... . Exporting a page layout uses the map document page width instead of df_export_width.

Note that pageSize property in the MapDocument class is 'Read Only'.

In this ESRI thread it is discussed that being able to change the map document size with Python would be complicated to implement.

On the other hand, there is the SetPageSize function which will allow customizing the page size of an input map document. Maybe you can use it at the beginning of your workflow?

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.