Select to view content in your preferred language

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

493
0
10-05-2020 08:24 AM
SadraDehghan1
Emerging Contributor

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.RefreshActiveView()
      arcpy.mapping.ExportToTIFF(mxd, os.path.join(path, "{}.tif".format(id)), df, df_export_width=2000,       df_export_height=2000, geoTIFF_tags=True)

Tags (2)
0 Kudos
0 Replies