创建空间参考 (Data Management)

许可等级:BasicStandardAdvanced

摘要

创建用于模型构建器的空间参考对象。

使用空间参考类可创建用于脚本的空间参考对象。

用法

语法

CreateSpatialReference_management ({spatial_reference}, {spatial_reference_template}, {xy_domain}, {z_domain}, {m_domain}, {template}, {expand_ratio})
参数说明数据类型
spatial_reference
(可选)

要创建的空间参考对象的名称。

Spatial Reference
spatial_reference_template
(可选)

要用作模板的要素类或图层,用于设置空间参考的值。

Feature Layer; Raster Catalog Layer; Raster Dataset
xy_domain
(可选)

允许的 x,y 坐标的坐标范围。

Envelope
z_domain
(可选)

允许的 z 值的坐标范围。

String
m_domain
(可选)

允许的 m 值的坐标范围。

String
template
[template,...]
(可选)

可用于定义 XY 属性域的要素类或图层。

Feature Layer
expand_ratio
(可选)

展开 XY 属性域时使用的百分比。

Double

代码实例

创建空间参考示例(独立脚本)

以下独立脚本将 CreateSpatialReference 函数用作工作流的一部分,该工作流在文件中进行循环、查找所有以“ST”结尾的 shapefile、创建空间参考,并将其追加到地理数据库要素类中。

# 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])

环境

此工具不使用任何地理处理环境

相关主题

许可信息

ArcGIS for Desktop Basic: 是
ArcGIS for Desktop Standard: 是
ArcGIS for Desktop Advanced: 是
5/10/2014