Modify map coordinate system with arcpy.mp?

6575
16
10-31-2016 08:31 AM
BryanChastain
New Contributor III

Is there any way to modify a map's coordinate system in ArcGIS Pro using Python?

0 Kudos
16 Replies
DanPatterson_Retired
MVP Emeritus

Define Projection or the Project tool are your options ... what are you looking to modify?

JoshuaBixby
MVP Esteemed Contributor

If by "map" you mean MapFrame, at ArcGIS Pro 1.3 there is no spatialReference method like there is for a DataFrame in ArcMap.  If you mean Map by "map," same issue, no method to access spatial reference.  Time to submit an enhancement request and ArcGIS Idea....

JosephMcGehan
New Contributor III

I need to read the map objects spatialReference properties. Picture that it's 2019 and Esri have GIS Software where you can't read spatial reference of a map.  

aprx_object = arcpy.mp.ArcGISProject(aprx)
m = aprx_object.listMaps()
for mp in m:
   ID = 0
   mapname = mp.name
   mp_projection = mp.spatialReference() # 

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

My guess is you know you can already manually make the change

Specify a coordinate system—Properties of maps | ArcGIS for Desktop 

(I think if you have a default basemap with a different spatial reference, that will also change to the basemaps spatial reference as default....one way to change it)

as Dan asked, what are you looking to modify? And to add, are you trying to do this once, or on-the-fly. Remember that all your layers may need to be reprojected on the fly as well.

some links to look at

Output Coordinate System (Environment setting)—Geoprocessing | ArcGIS for Desktop 

Using the spatial reference class—ArcPy Get Started | ArcGIS for Desktop 

Specify a coordinate system—Properties of maps | ArcGIS for Desktop 

SpatialReference—ArcPy Classes | ArcGIS for Desktop 

0 Kudos
BryanChastain
New Contributor III

Rebecca Strauch, GISP & Dan_Patterson, sorry I meant change the spatial reference for either an arcpy.mp.Map or arcpy.mp.MapFrame.

According to bixb0012‌, looks like it's not possible. If that's true, that's a shame. It will be hard to come up with a Python-based workaround for that limitation.

DanPatterson_Retired
MVP Emeritus

add an empty data frame, add a layer in the coordinate system you want... the dataframe coordinate system is now set... add/copy your other layers over and remove the 'seed' layer... done... depends how hard you need to have it done

0 Kudos
BryanChastain
New Contributor III

Pro doesn't have data frames. Do you mean a Map? The only way I see to programmatically create a new map is to call the arcpy.mp.ArcGISProject.importDocument() function. However, that would require you to have an mxd pre-authored for any coordinate system the user might want to change to. Then you'd still have to copy over all the existing layers into the new map. Also, if the map had already been used in a MapFrame in a Layout, then you'd really run into some issues...

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Unlike most ArcPy modules, ArcPy Mapping (arcpy.mp) had to be rewritten from the ground up since the UI and structure of ArcGIS Pro is completely different than ArcMap.  They will be playing catch up for quite some time, which is why it is important for people to open enhancement requests and create ArcGIS Ideas.  There is a lot to port over from ArcMap to ArcGIS Pro, and without user feedback, Esri is left to either do what is easiest first or guess at what users want.

BryanChastain
New Contributor III