Select to view content in your preferred language

How to create a Python Toolbox or ModelBuilder used for finding latitude, longitude in basemap and zooming in 500 meters.

741
1
01-05-2021 11:47 PM
nutchanaka
New Contributor

How to create a Python Toolbox or ModelBuilder in ArcGIS Pro used for finding latitude, longitude in basemap And when the search is complete, zoom in at 500 meters.

1 Reply
Erwinvan_Veen1
Regular Contributor

You could try something like the following. The script is inspired by this question.

Please note I did not get the scale property to work, so you could try specifying your own scale.

import arcpy
currentProject = arcpy.mp.ArcGISProject('current')
activeObject = currentProject.activeView
x = float(arcpy.GetParameterAsText(0))
y = float(arcpy.GetParameterAsText(1))
yourScale = float(arcpy.GetParameterAsText(2))
xMin = x-yourScale
yMin = y-yourScale
xMax = x+yourScale
yMax = y+yourScale
extent = arcpy.Extent(xMin,yMin,xMax,yMax)
activeObject.camera.setExtent(extent)

Some notes:

- This script assumes you are working in the map you wish to change the view in.

- You can enter the coordinates by hand (hence the GetParameterAsText for x and y) and it assumes you already know the coordinates you are looking for (for example from an Excel file).

- The scale is used to create a square of sorts to set the extent. You may have to alter this to suit your needs.

- The scale is now published as parameter. You could hardcode this or provide a default value.

If this is not really what you are looking for, could you please elaborate what the script should do?