I feel like this should be a lot easier than it is, all I am trying to do is create a geotiff that contains spatial referencing from arcmap in an automated manner as I have thousands to create. Currently I have a script that is creating the exact map I need from the Data View. A mxd sets the dataframe area I require and I set the scale and center the map which then produced the tiff output

# Get the location of the output directory to save the exported map
outTIFFpath = arcpy.GetParameterAsText(9)

# Export the WebMap
arcpy.AddMessage("Exporting to TIFF")
arcpy.mapping.ExportToTIFF(mxd, outTIFFpath, resolution=150, color_mode="8-BIT_PALETTE")

Problem is the map produced does not contain a spatial reference, this is the last hurdle. If I try to add geoTIFF_tags=True then my script fails. I believe this all comes down to not being able to create a geotiff from the layout view. I have about 7000 of these I need to create.

I can do it manually from the Layout view using the following info and selecting Layout GeoTiff as I have a production mapping licence it seems to work fine when I try to do it from ArcMap.

How can I automate this selection of the Layout Geotiff as part of my script?



it is a bit strange to write a full layout view as a georeferenced tif, and maybe this is why it fails. You should export To tif only one of your dataframe (the rectangle cntaining the data in the layout view), then you could use a worldfile or geoTIFF_tag=True to have a georeferenced image. Note that, when exporting dataframe, you need to change the df_export_width and df_export_height parameters to alter image detail. The height and width parameters directly control the number of pixels generated in the export file and are only used when exporting a data frame (you then need to keep the resolution parameter at its default value).

arcpy.mapping.ExportToTIFF(mxd, outTIFFpath, arcpy.mapping.ListDataFrames(mxd)[0], df_export_width=1000, df_export_height=1000, color_mode="8-BIT_PALETTE" , geoTIFF_tags=True) #define the width and height based on your data
  • Thanks for the reply, yes I have tried the above previously and I do get a correctly referenced geotif but it only contains a small part of my required output area. When I use the data frame I guess this defines the area I require. Maybe my issue is setting the extents of the TIFF I require to extract in the data view? – Ciara B Jan 19 at 21:59
  • well, that's another problem indeed. How do you set the extent of your files ? With DataDrivenPages ? Based on a selected layer ? Based on a regular grid ? – radouxju Jan 19 at 22:14

Looks like this could be my answer http://desktop.arcgis.com/en/arcmap/latest/extensions/production-mapping/setpagesize-function.htm

Though I am sure if I was more experienced I could do it properly through arcpy.mapping.ExportToTIFF

import arcpy
import arcpyproduction

# Check out Production Mapping extension

# Define variables
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
out_tiff = r"C:\Project\GeoTIFFs\Project.tif"
df = arcpy.mapping.ListDataFrames(mxd, "Main")[0]

# Run function with only the required parameters defined
arcpyproduction.mapping.ExportToLayoutGeoTIFF(mxd, out_tiff, df, world_file="True")

# Check in extension

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.