Summary
Creates a spatial reference for use in ModelBuilder.
Usage
You can create a spatial reference with a set coordinate system, spatial domains, and precision. The spatial domains and precision of the output spatial reference can be further modified using the XY Domain, Z Domain, M Domain, Template XYDomains, and Grow XYDomain By Percentage parameters.
XY, Z, and M extents are not the same as spatial reference domains. The XY, Z, and M domains in a spatial reference define the valid range of coordinate values that can be stored in a feature class. The feature class extents reflect the actual range of coordinate values that exist in the feature class. These extents cannot be larger than the domains.
The Template XYDomains parameter does not have to be in the same coordinate system as that specified in Spatial Reference or Spatial Reference Template. If they are different, the extents will be projected to match.
If the Spatial Reference and Spatial Reference Template parameters are both set, the Spatial Reference parameter will take priority.
All the parameters of the tool are optional. If no parameters are specified, the spatial reference will be defined as Unknown, and the XY Domain will assume standard defaults.
In ModelBuilder, the output of this tool can be used as input to tools with a spatial reference parameter (for example, Create Feature Class, Create Feature Dataset, and Make XY Event Layer).
In Python, the SpatialReference class can also be used to create a spatial reference.
Syntax
arcpy.management.CreateSpatialReference({spatial_reference}, {spatial_reference_template}, {xy_domain}, {z_domain}, {m_domain}, {template}, {expand_ratio})
Parameter | Explanation | Data Type |
spatial_reference (Optional) | The name of the spatial reference to be created. | Spatial Reference |
spatial_reference_template (Optional) | The feature class or layer to be used as a template to set the value for the spatial reference. | Feature Layer; Raster Dataset |
xy_domain (Optional) | The allowable coordinate range for x,y coordinates. | Envelope |
z_domain (Optional) | The allowable coordinate range for z-values. | String |
m_domain (Optional) | The allowable coordinate range for m-values. | String |
template [template,...] (Optional) | The feature classes or layers that can be used to define the XY Domain. | Feature Layer |
expand_ratio (Optional) | The percentage by which the XY Domain will be expanded. | Double |
Derived Output
Name | Explanation | Data Type |
out_spatial_reference | The output spatial reference. In ModelBuilder, the output of this tool can be used as input to tools with a spatial reference parameter (for example, Create Feature Class, Create Feature Dataset, and Make XY Event Layer). | Spatial Reference |
Code sample
The following stand-alone script uses the CreateSpatialReference function as part of a workflow that loops through a folder and finds all shapefiles that end in ST, creates spatial references, and appends them into a geodatabase feature class.
# This script reprojects a shapefile in Redlands folder
# from NAD 1983 UTM Zone 11N
# to NAD 1983 StatePlane California V FIPS 0405 (US Feet)
# import system modules
import arcpy
try:
# set the workspace environment
arcpy.env.workspace = r"C:\data\Redlands"
# create a spatial reference object to be used as output coordinate system
out_sr = arcpy.CreateSpatialReference_management("NAD 1983 StatePlane California V FIPS 0405 (US Feet)")
# use the output of CreateSpatialReference as input to Project tool
# to reproject the shapefile
arcpy.Project_management("citylimit_Project1.shp", "city_CA_FIPS0405", out_sr)
except arcpy.ExecuteError:
# print geoprocessing message
print(arcpy.GetMessages(2))
except Exception as ex:
# print the exception message
print(ex.args[0])
Environments
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes