I am using notebooks and arc py to do a definition query, after the def query is done I want to zoom to the layer. I cannot seem to find documentation on how to do this, I have figured out the definition query and it works well as seen below-
import arcpy
# Set the project path to "CURRENT" to use the currently open project
project_path = "CURRENT"
# Set the name of the map and the layer you want to apply the definition query to
map_name = 'main'
layer_name = 'prop'
# Set the field and value for the definition query
field_name = 'id'
query_value = input('Enter the ID')
# Create a reference to the ArcGIS Pro project
aprx = arcpy.mp.ArcGISProject(project_path)
# Access the map and the layer
map_obj = aprx.listMaps(map_name)[0]
layer_obj = map_obj.listLayers(layer_name)[0]
# Set a simple definition query
definition_query = f"{field_name} = '{query_value}'"
layer_obj.definitionQuery = definition_query
Solved! Go to Solution.
You might want to look around the camera properties to see if it is possible
Camera—ArcGIS Pro | Documentation
You might want to look around the camera properties to see if it is possible
Camera—ArcGIS Pro | Documentation
This worked thanks!