8

According to documentation, the options are: Syntax

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

However, this works:

import arcpy.mapping
mxd = arcpy.mapping.MapDocument("CURRENT")
arcpy.mapping.ListDataFrames(mxd)
arcpy.mapping.ExportToTIFF(mxd,r"D:\out2.tif","PAGE_LAYOUT",640,480,96)

but this:

arcpy.mapping.ExportToTIFF(mxd,r"D:\out2.tif","PAGE_LAYOUT",640,480,96,True)

yields: Runtime error <type 'exceptions.TypeError'>: PageLayoutObject: Error in executing ExportToTIFF

Am I doing something wrong with that Boolean for world_file?

3 Answers 3

11

I believe the World file option is only available if you export from a data frame, not the page layout.

From Exporting your Map

TIFF-specific options

The TIFF file format has the additional ability to store georeferencing information internally. This is a GeoTIFF. To create a GeoTIFF, click the Save as type drop-down arrow and click TIFF, click the Options arrow to expand the options, then click the Format tab and check Write GeoTIFF Tags. This option is only available when you export while in data view.

While this information relates to exporting from the UI, the same logic probably applies to ArcPy.

I just tested this, and the world file option works with a data frame, while the "PAGE_LAYOUT" yields an error. This makes sense because the page layout is in page coordinates i.e. (0,0) to (page_width, page_height) not real world coordinates.

Warning, this tool does not work as you may expect. (I'm using ArcGIS Desktop 10.0 SP1). If the specified image size does not have the same aspect ratio as the data frame, unseen portion of the data frame are exported to fill the image. However, the x and y pixel scaling in the world file is based on the extents of the data frame shown, not as expanded for the image.

If you use the UI tool (File->Export Map...), you will notice that the image size is preset to the aspect ratio of the data frame and you cannot change the image size except by changing the image resolution.

A work around is to get the extents of the data frame, and then calculate the image aspect ratio to match. Like so:

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
ar = df.extent.height / df.extent.width
arcpy.mapping.ExportToTIFF(mxd,r"C:\out.tif",df,1024,1024*ar,96,True)
1
  • correct only from a Data Frame (real world coordinates)
    – Mapperz
    Commented Dec 17, 2010 at 4:06
0

I believe what you are looking for is: mxd.pageSize.height * (conversion_factor * DPI)

You can combine conversion_factor * DPI into one constant, or keep them separate and convert between whatever units are specified in the Map Page Size section of the Page and Print Setup window.

0

Let ExportToTIFF create a geotiff. Then use ExportRasterWorldFile_management (data_management\raster\raster properties) to generate the world file. This tool is valid at all license levels.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.