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

4734
6
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 Esteemed Contributor
6 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.
Tags (1)
SterlingL
New Contributor II

Thank you sir! This worked marvelously.

Katerina1
New Contributor

Hi Mark,

Can you please indicate how to save the extent as a feature class? I tried InsertCursor but it didn't accept the polygon object, it requires list of floats instead.
Many thanks,

Katerina.

0 Kudos
DanPatterson
MVP Esteemed Contributor

Using tools in ArcToolbox

Create Fishnet (Data Management)—ArcGIS Pro | Documentation

aoi_create_fishnet.png

 

aoi_create_fishnet1.png

 


... sort of retired...
SterlingL
New Contributor II

Dan this works great as well! Thank you.

VeraNeroni1
New Contributor II

This worked great! Thank you!

0 Kudos