Is there a way to create a polygon from a map frame extent in ArcGIS Pro?

315
4
Jump to solution
01-07-2021 04:11 PM
SterlingL
New Contributor II
 
Tags (3)
2 Solutions

Accepted Solutions
MarkBryant
New Contributor III

You can do it via code.

 

import arcpy
#Reference the Project document from within PRO
aprx = arcpy.mp.ArcGISProject("CURRENT")
#Reference the layout
lyt = aprx.listLayouts("your_layout_name_here")[0]
#Get the Map Frame
mf = lyt.listElements("mapframe_element", "your_mapframe_name")[0]
extent = mf.camera.getExtent()
polygon = extent.polygon

 

You then have a polygon object that you can work with.

Note that this code just grabs the extent, if the map frame is rotated, the extent doesn't match what you see on screen.

Mark.

View solution in original post

Tags (1)
DanPatterson
MVP Frequent Contributor
4 Replies
MarkBryant
New Contributor III

You can do it via code.

 

import arcpy
#Reference the Project document from within PRO
aprx = arcpy.mp.ArcGISProject("CURRENT")
#Reference the layout
lyt = aprx.listLayouts("your_layout_name_here")[0]
#Get the Map Frame
mf = lyt.listElements("mapframe_element", "your_mapframe_name")[0]
extent = mf.camera.getExtent()
polygon = extent.polygon

 

You then have a polygon object that you can work with.

Note that this code just grabs the extent, if the map frame is rotated, the extent doesn't match what you see on screen.

Mark.

View solution in original post

Tags (1)
SterlingL
New Contributor II

Thank you sir! This worked marvelously.

DanPatterson
MVP Frequent Contributor
SterlingL
New Contributor II

Dan this works great as well! Thank you.