Arcpy Zoom to Point

611
6
10-09-2018 03:20 PM
Highlighted
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. 

Reply
0 Kudos
6 Replies
Highlighted
MVP Esteemed Contributor

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

Reply
0 Kudos
Highlighted
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.

Reply
0 Kudos
Highlighted
Regular Contributor

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

arcpy.mp
Reply
0 Kudos
Highlighted
Regular Contributor

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

 

mf.camera.setExtent(<extent>)

or

mf.camera.getExtent()
Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

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 

Highlighted
Regular 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.

Reply
0 Kudos