Select to view content in your preferred language

Arcpy Zoom to Point

2347
6
10-09-2018 03:20 PM
DaneMyers1
New Contributor

I have coordinates from a point that I want to move to. I typically use the zoom to x,y on arc desktop but I am trying to automate the process using arcpy. I can't seem to figure out how to use the coordinates to move the extent with the point in the middle and then a scale at 50000. 

0 Kudos
6 Replies
DanPatterson_Retired
MVP Emeritus

What is your script? and are you using arcpy mxd with 'CURRENT' in the mapping module? and does it include a refresh?

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

The basics are covered here:  arcgis desktop - Using ArcPy to zoom to Y,X (string) coordinate pair copy/pasted from Google Maps? -... 

x,y = # tuple containing x,y coordinates
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
df.panToExtent(arcpy.Extent(x,y,x,y))
df.scale = 5000
arcpy.RefreshActiveView()‍‍‍‍‍‍‍‍‍‍‍‍

Extent—Help | ArcGIS Desktop  doesn't work with spatial references directly so you will want to make sure the coordinates you are passing are already in the same coordinate system of the data frame.

0 Kudos
Arne_Gelfert
Frequent Contributor

Is there anything like it the arcpy that ships with Pro? It's certainly not in...

arcpy.mp
0 Kudos
Arne_Gelfert
Frequent Contributor

Looks like it may now be handled using the Camera—ArcPy | ArcGIS Desktop and 

 

mf.camera.setExtent(<extent>)

or 

mf.camera.getExtent()
0 Kudos
DanPatterson_Retired
MVP Emeritus

Arne Gelfert‌ This link provides some explanations and the diagram shows the inter-relationships and what has moved and where.

Migrating from arcpy.mapping to ArcGIS Pro—ArcPy | ArcGIS Desktop 

Arne_Gelfert
Frequent Contributor

Thanks, Dan... I'll check it out. Camera.extent was a good start. Even easier, it appears, will be to just use camera.X/camera.Y.

0 Kudos