Sunday, 2 April 2017

arcgis pro - Querying for extent of layer in arcpy.mp?


We're migrating automated mapping scripts from ArcGIS Desktop to ArcGIS Pro — Python 2.7 to 3, arcpy.mapping module to arcpy.mp module. All these scripts iterate through a loop to select various features of interest, and then focus the dataframe extent on that selection. For example:


gas_main_layer = arcpy.mapping.ListLayers(mxd, "GasMain", data_frame)[0]
data_frame.extent = gas_main_layer.getSelectedExtent()
# adjust scale slightly so view is larger than polygon extent
data_frame.scale *= 1.2


I easily figured out how to transition ListLayers to the new mapping module's workflow, but I can't find a comparable method on the Layer class to get the selected extent and then reset the zoom/extent of its Map. What is the way to get the same functionality out of the new module?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...