SpatialReference (arcpy)
摘要
空间参考的每一部分都具有多个属性,特别是坐标系,它定义了哪些地图投影选项用于定义水平坐标。
讨论
也可使用 Describe spatialReference 属性从现有数据集访问 SpatialReference 对象。
dataset = "C:/Data/Landbase.gdb/Wetlands"
spatialRef = arcpy.Describe(dataset).spatialReference
注:空间参考属性的可用性取决于所使用的坐标系。在下面的属性列表中,只可用于投影坐标系的属性以 1 表示;只可用于地理坐标系的属性以 2 表示。
语法
| 参数 | 说明 | 数据类型 |
item |
The spatial reference can be created in three ways:
For more information on coordinate system names and factory codes, see geographic_coordinate_systems.pdf and projected_coordinate_systems.pdf files in the ArcGIS Documentation folder. For more information, see Using the spatial reference class. | String |
属性
| 属性 | 说明 | 数据类型 |
| GCS (只读) |
If a projected coordinate system, returns a SpatialReference object for the geographic coordinate system it is based on. If a geographic coordinate system, returns the same SpatialReference. | SpatialReference |
| MDomain (只读) |
The extent of the measure domain. | String |
| MFalseOriginAndUnits (只读) |
The measure false origin and units. | String |
| MResolution (读写) |
The measure resolution. | Double |
| MTolerance (读写) |
The measure tolerance. | Double |
| XYResolution (读写) |
The xy resolution. | Double |
| XYTolerance (读写) |
The xy tolerance. | Double |
| ZDomain (只读) |
The extent of the Z domain. | String |
| ZFalseOriginAndUnits (只读) |
The Z false origin and units. | String |
| ZResolution (读写) |
The Z resolution property. | Double |
| ZTolerance (读写) |
The Z tolerance property. | Double |
| abbreviation (读写) |
The abbreviated name of the spatial reference. | String |
| alias (读写) |
The alias of the spatial reference. | String |
| domain (只读) |
The extent of the xy domain. | String |
| factoryCode (读写) |
The factory code of the spatial reference. | Integer |
| falseOriginAndUnits (只读) |
The false origin and units. | String |
| hasMPrecision (只读) |
Indicates whether or not m-value precision information has been defined. | Boolean |
| hasXYPrecision (只读) |
Indicates whether or not xy precision information has been defined. | Boolean |
| hasZPrecision (只读) |
Indicates whether or not z-value precision information has been defined. | Boolean |
| isHighPrecision (读写) |
Indicates whether or not the spatial reference has high precision set. | Boolean |
| name (读写) |
The name of the spatial reference. | String |
| remarks (读写) |
The comment string of the spatial reference. | String |
| type (读写) |
The type of the spatial reference. | String |
| usage (只读) |
The usage notes. | String |
| PCSCode (读写) |
The projected coordinate system code.1 | Integer |
| PCSName (读写) |
The projected coordinate system name.1 | String |
| azimuth (读写) |
The azimuth of a projected coordinate system.1 | Double |
| centralMeridian (读写) |
The central meridian of a projected coordinate system.1 | Double |
| centralMeridianInDegrees (读写) |
The central meridian (Lambda0) of a projected coordinate system in degrees.1 | Double |
| centralParallel (读写) |
The central parallel of a projected coordinate system.1 | Double |
| classification (只读) |
The classification of a map projection.1 | String |
| falseEasting (读写) |
The false easting of a projected coordinate system.1 | Double |
| falseNorthing (读写) |
The false northing of a projected coordinate system.1 | Double |
| latitudeOf1st (读写) |
The latitude of the first point of a projected coordinate system.1 | Double |
| latitudeOf2nd (读写) |
The latitude of the second point of a projected coordinate system.1 | Double |
| linearUnitCode (读写) |
The linear unit code.1 | Integer |
| linearUnitName (读写) |
The linear unit name.1 | String |
| longitude (读写) | The longitude value of this prime meridian.1 | Double |
| longitudeOf1st (读写) |
The longitude of the first point of a projected coordinate system.1 | Double |
| longitudeOf2nd (读写) |
The longitude of the second point of a projected coordinate system.1 | Double |
| longitudeOfOrigin (读写) |
The longitude of origin of a projected coordinate system.1 | Double |
| projectionCode (读写) |
The projection code.1 | Integer |
| projectionName (读写) |
The projection name.1 | String |
| scaleFactor (读写) |
The scale factor of a projected coordinate system.1 | Double |
| standardParallel1 (读写) |
The first parallel of a projected coordinate system.1 | Double |
| standardParallel2 (读写) |
The second parallel of a projected coordinate system.1 | Double |
| GCSCode (读写) |
The geographic coordinate system code.2 | Integer |
| GCSName (读写) |
The geographic coordinate system name.2 | String |
| angularUnitCode (读写) |
The angular unit code.2 | Integer |
| angularUnitName (读写) |
The angular unit name.2 | String |
| datumCode (读写) |
The datum code.2 | Integer |
| datumName (读写) |
The datum name.2 | String |
| flattening (读写) |
The flattening ratio of this spheroid.2 | Double |
| longitude (读写) |
The longitude value of this prime meridian.2 | Double |
| primeMeridianCode (读写) |
The prime meridian code.2 | Integer |
| primeMeridianName (读写) |
The prime meridian name.2 | String |
| radiansPerUnit (只读) |
The radians per angular unit.2 | Double |
| semiMajorAxis (读写) |
The semi-major axis length of this spheroid.2 | Double |
| semiMinorAxis (读写) |
The semi-minor axis length of this spheroid.2 | Double |
| spheroidCode (读写) |
The spheroid code.2 | Integer |
| spheroidName (读写) |
The spheroid name.2 | String |
方法概述
| 方法 | 说明 |
| create () |
Creates the spatial reference object using properties. |
| createFromFile (prj_file) |
Creates the spatial reference object from a projection file. |
| exportToString () |
Exports the object to its string representation. |
| loadFromString (string) |
Restore the object using its string representation. The exportToString method can be used to create a string representation. |
| setDomain (x_min, x_max, y_min, y_max) |
设置 XY 属性域。 |
| setFalseOriginAndUnits (false_x, false_y, xy_units) |
Sets the XY false origin and units. |
| setMDomain (m_min, m_max) |
Sets the M domain. |
| setMFalseOriginAndUnits (false_m, m_units) |
设置 M 的假定原点和单位。 |
| setZDomain (z_min, z_max) |
Sets the Z domain. |
| setZFalseOriginAndUnits (false_z, z_units) |
设置 Z 的假定原点和单位。 |
方法
| 参数 | 说明 | 数据类型 |
prj_file |
The projection file used to populate the spatial reference object. | String |
| 数据类型 | 说明 |
| String |
The string representation of the object. |
| 参数 | 说明 | 数据类型 |
string |
The string representation of the object. | String |
| 参数 | 说明 | 数据类型 |
x_min |
The minimum x-value. | Double |
x_max |
The maximum x-value. | Double |
y_min |
The minimum y-value. | Double |
y_max |
The maximum y-value. | Double |
| 参数 | 说明 | 数据类型 |
false_x |
The false x value. | Double |
false_y |
The false y value. | Double |
xy_units |
The xy units. | String |
| 参数 | 说明 | 数据类型 |
m_min |
The minimum m-value. | Double |
m_max |
The maximum m-value. | Double |
| 参数 | 说明 | 数据类型 |
false_m |
The false m-value. | Double |
m_units |
The m units. | Double |
| 参数 | 说明 | 数据类型 |
z_min |
The minimum z-value. | Double |
z_max |
The maximum z-value. | Double |
| 参数 | 说明 | 数据类型 |
false_z |
The false z-value. | Double |
z_units |
The false z units. | Double |
代码实例
对工作空间中的每个要素类,输出其空间参考的名称。
import arcpy
from arcpy import env
# Set the workspace environment
#
env.workspace = "C:/base/base.gdb"
# Get a list of the feature classes in the input folder
#
fcs = arcpy.ListFeatureClasses()
# Loop through the list
#
for fc in fcs:
# Create the spatial reference object
#
sr = arcpy.Describe(fc).spatialReference
# If the spatial reference is unknown
#
if sr.name == "Unknown":
print fc + " has an unknown spatial reference\n"
# Otherwise, print out the feature class name and
# spatial reference
#
else:
print fc + ": " + sr.name + "\n"