HOW TO
A spatial reference is the coordinate system used to store the location of each feature class and raster dataset, as well as other coordinate properties such as the coordinate resolution for x,y coordinates, and optional z and m coordinates. For more information about spatial references, refer to the following web help document, ArcGIS Desktop: An overview of spatial references.
Retrieving multiple spatial references can take a long time. As an alternative, the feature class spatial reference can be retrieved by using the ArcPy function, arcpy.Describe() and the spatialReference ArcPy class. The script can be modified to use loop expressions to iterate between all existing feature classes in a file geodatabase.
The following steps demonstrate how to iterate between feature classes and print spatial reference of feature classes using a Python script:
import arcpy arcpy.env.workspace = r"[WORKSPACE_NAME]"
Note: To use the current default workspace, replace the environmental workspace parameter as follows: arcpy.env.workspace = arcpy.GetParameterAsText(0)
feature_classes = arcpy.ListFeatureClasses() print feature_classes
for fc in feature_classes: spatial_ref = arcpy.Describe(fc).spatialReference
if spatial_ref.name == "Unknown": print("{0} has an unknown spatial reference".format(fc)) else: print("{0} : {1}".format(fc, spatial_ref.name))
import arcpy # Set the workspace environment arcpy.env.workspace = arcpy.GetParameterAsText(0) # Get a list of the feature classes in the input folder feature_classes = arcpy.ListFeatureClasses() print feature_classes ### Loop through the list for fc in feature_classes: # Create the spatial reference object spatial_ref = arcpy.Describe(fc).spatialReference # If the spatial reference is unknown if spatial_ref.name == "Unknown": print("{0} has an unknown spatial reference".format(fc)) # Otherwise, print out the feature class name and # spatial reference else: print("{0} : {1}".format(fc, spatial_ref.name))
Get help from ArcGIS experts
Download the Esri Support App