HOW TO
Identifying the spatial reference of layers on a map in an ArcGIS Pro project is helpful in ensuring the layers are accurately projected. In ArcGIS Pro, it is possible to create a spatial reference list of the layers available on the map via ArcPy.
Depending on the project's file format, the workflows described below are applicable.
Specify the Python script to run a project file (.aprx) in the Python window
The following steps demonstrate how to specify the Python script to run a project file (.aprx) in the ArcGIS Pro Python window.
Import arcpy
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("<Map_Name>")[0]
for lyr in m.listLayers(): spatial_ref = arcpy.Describe(lyr).spatialReference print(lyr.name, spatial_ref.name)
The code below shows the full working script.
import arcpy aprx = arcpy.mp.ArcGISProject("CURRENT") m = aprx.listMaps("Map_Sample")[0] for lyr in m.listLayers(): spatial_ref = arcpy.Describe(lyr).spatialReference print(lyr.name, spatial_ref.name)
Note: The “AttributeError: DescribeData: Method spatialReference does not exist” error message can be ignored as the Describe() function does not consider basemaps as layers in the operation.
Specify the Python script to run a file geodatabase (FGDB) in the Python window
In ArcGIS Pro, specify the Python script to run a file geodatabase (FGDB) in the ArcGIS Pro Python window. Refer to ArcGIS Pro: Code sample for instructions.
Note: The Describe() function can be run using a stand-alone Python script by creating a Python file.
Get help from ArcGIS experts
Download the Esri Support App