Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

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 regret I can't test it right now.

EDIT: I just tested it, 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.

EDIT#2: Warning, this tool does not work as you may expect. (I'm using Arc10sp1). 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)
share|improve this answer
    
correct only from a Data Frame (real world coordinates) –  Mapperz Dec 17 '10 at 4:06
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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