josepharmbruster0lat

ExportToTif width / height calculation

Discussion created by josepharmbruster0lat on Oct 2, 2013
Latest reply on Oct 4, 2013 by jbarrette-esristaff
I am using arcpy to export of a dataframe to geotiff.  The dataframe contains all of the feature / raster data for a JOG sheet.  The code looks like this:

dpi = 300
output_tif = #... path to the output geotiff
path_to_mxd = # ... contains the path to the mxd of interest

mxd = arcpy.mapping.MapDocument(path_to_mxd)

# we assume basemap exists...
target_data_frame = arcpy.mapping.ListDataFrames(mxd, 'BaseMap')[0]

mxd.activeView = target_data_frame

arcpy.mapping.ExportToTIFF(
  map_document = mxd,
  out_tif = output_tif,
  data_frame = target_data_frame,
  resolution = dpi,
  world_file = True,
  color_mode = '24-BIT_TRUE_COLOR',
  tiff_compression = 'NONE',
  geoTIFF_tags=True)

After exporting, I end up with a 640x480 image.  For the content of a JOG map sheet, this is obviously not what I want.  There are two additional parameters I can provide to this function; df_export_width and df_export_height but I am not certain how they should be calculated using only the meta-data that is available via the arcpy interfaces (mapdocument, pagesize, elementsizes / etc...).  I would like to reproduce the exact-width and height values for a given DPI, the same way the "Export Map" dialog calculates it within arcmap.  The detail here is that I am using a dataframe, not a layout view.  For layout view, the formula is trivial:
- df_export_width = mxd.pageSize.width * conversion_factor * dpi
- df_export_height = mxd.pageSize.height * conversion_factor * dpi

In my case, the page units are centimters, so the conversion factor is 0.393701.  Obviously, this logic does-not make sense when using a dataframe...

So what is the formula for width and height when using a data frame?

Thank You in advance.

Outcomes