Select to view content in your preferred language

get current Map extent with correct mapUnits in ArcGIS Pro using arcpy?

782
2
03-11-2023 06:41 AM
schenardi
Regular Contributor

How can I get the current maps extent with configured mapUnits?

Two examples always return the unit of the map projection (Meters) instead of the configured mapUnits (degrees).

 

 

av = aprx.listMaps('Map')[0]
print(av.name)
av.mapUnits

 

 

Result: 'Meter'

 

 

from arcpy import mp
aprx = mp.ArcGISProject("CURRENT")

currentExtent = aprx.activeView.camera.getExtent()
print(currentExtent)

 

 

Result: 

2697655.50805199 1234784.44214015 2703943.289983 1243768.44124222 NaN NaN NaN NaN

 

Screenshot of my ArcGIS Pro and the Notebook:

schenardi_laixo_1-1678545585769.png

 

 

Tags (3)
0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

You might not be able to directly from the cim but you can use projectAs in the extent class

Extent—ArcGIS Pro | Documentation

to convert from the existing extent with its spatial reference (PCS) to a new spatial reference (GCS)


... sort of retired...
0 Kudos
ShaunWalbridge
Esri Regular Contributor

Dan's suggestion is a good one. You could also log an idea for getting the display units from the map, which differ from the map units.

0 Kudos