AnsweredAssumed Answered

Python script to zoom to object and export screen (GeoTIFF) for ArcGIS pro

Question asked by Sadra.PW on Oct 5, 2020

I'm looking to build a script for ArcGIS pro which takes a feature class, zooms into the objects, and export a GeoTIFF named by an attribute from the feature. I'm new to ArcGIS pro and haven't done any scripting in it before but have the script below which I built for ArcMap. I'm having trouble bringing this script into ArcGIS pro and I'd appreciate any help with transitioning the script. Thanks!



import os
import arcpy


path = arcpy.GetParameterAsText (0)
lyr_prnt = arcpy.GetParameterAsText (1)
fld_name = arcpy.GetParameterAsText (2)
scale = None


mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]


with arcpy.da.SearchCursor(lyr_prnt, [fld_name, "SHAPE@"]) as cursor:
   for id, shape in cursor:
      selx = "{}".format(fld_name) + " = " + "'{}'".format(id)
      arcpy.SelectLayerByAttribute_management (lyr_prnt,"NEW_SELECTION", selx)
      df.extent = shape.extent
      if scale:
         df.scale = scale
      arcpy.mapping.ExportToTIFF(mxd, os.path.join(path, "{}.tif".format(id)), df, df_export_width=2000,       df_export_height=2000, geoTIFF_tags=True)