4

Steps:

  1. I am loading an aprx from a template, which is in WGS84 spatial reference.
  2. Then I do some processes.
  3. Finally, I want to change the MAP's spatial reference (WGS84) to another, which I get from another layer.

Is it possible to do it using arcpy and ArcGIS Pro?

The code is:

aprx = arcpy.mp.ArcGISProject(r"\\ptemplate\project.aprx)

ras= "my_layer.tif"

sr=arcpy.Describe(ras).spatialReference

aprxMap = aprx.listMaps()[0]

How do I change the Spatial Reference to _sr_?

aprx.saveACopy(r"\\my_projects\project_out.aprx)

1 Answer 1

8

You're pretty much there with your code. You just need to apply the SR on the map

ras= "my_layer.tif"
sr=arcpy.Describe(ras).spatialReference

p = arcpy.mp.ArcGISProject(r"\\ptemplate\project.aprx")
m = p.listMaps()[0]
m.spatialReference = sr
p.saveACopy(r"\\my_projects\project_out.aprx)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.