ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

帮助

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • 更多...

使用空间参考类

  • 创建空间参考

地理数据集(如要素类、coverage 和栅格)具有一个空间参考,用于定义数据集的坐标系、x,y 属性域、m 属性域和 z 属性域。空间参考的每一部分都具有多个属性,特别是坐标系,它定义了哪些地图投影选项用于定义水平坐标。所有这些信息都可以通过描述数据集并访问其空间参考属性获取,该属性实际上是另一个包含多个属性的对象。

import arcpy

# Describe a feature class
#
fc = "D:/St_Johns/data.gdb/roads"
desc = arcpy.Describe(fc)

# Get the spatial reference 
#
sr = desc.spatialReference

# Check if the feature class is in projected space
#
if sr.type == "Projected":
    arcpy.Copy_management(fc,"D:/St_Johns/data.gdb/roads_UTM")

创建空间参考

将一个空间参考的所有详细信息都保存在一个 Python 脚本中通常不太现实。通过将投影文件、工厂代码或空间参考名称用作 SpatialReference 类的参数,您可以快速完成空间参考属性的设置并将对象作为地理处理工具的输入。在下面的示例中,将使用提供的工厂代码(也称之为权限代码)作为输入参数来构造空间参考。

提示:

有关坐标系名称和工厂代码的详细信息,请参阅 ArcGIS 文档文件夹中的 geographic_coordinate_systems.pdf 和 projected_coordinate_systems.pdf 文件。

import arcpy

inputWorkspace = "c:/temp"
outputName =  "rivers.shp"

# Get the input workspace, the output name for the new feature class
#  and path to an input projection file
#
inputWorkspace = arcpy.GetParameterAsText(0)
outputName     = arcpy.GetParameterAsText(1)
factoryCode    = arcpy.GetParameterAsText(2)

# Use a code as input to the SpatialReference class
#
sr = arcpy.SpatialReference(factoryCode)

# Use the SpatialReference object to create a new feature class with a 
#  specific coordinate system
#
arcpy.CreateFeatureclass_management(inputWorkspace, outputName, 
                                    "POLYLINE", spatial_reference=sr)
注:

要获取属性和方法的完整列表,请参阅 SpatialReference 类。

注:

空间参考有时被称为“投影引擎”字符串。投影引擎 (PE) 是一个代码库,所有 ArcGIS 产品均使用此代码库来定义地图投影和执行从一个投影到另一个投影的变换。

相关主题

  • SpatialReference

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • Esri 博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2019 Esri. | 隐私政策 | 法律声明