Zusammenfassung
Each part of the spatial reference has a number of properties (especially the coordinate system) that defines what map projection options are used to define horizontal coordinates.
Auswertung
A SpatialReference object can also be accessed from existing datasets using the Describe spatialReference property.
dataset = "c:/data/landbase.gdb/Wetlands"
spatial_ref = arcpy.Describe(dataset).spatialReference
Syntax
SpatialReference ({item}, {vcs})
Parameter | Erläuterung | Datentyp |
item | The coordinate system to be used to create the SpatialReference. Can be set using a projection file, name, factory code, or well-known text (WKT) format. See examples below.
For more information on coordinate system names and factory codes, see geographic_coordinate_systems.pdf and projected_coordinate_systems.pdf files. For more information, see Using the spatial reference class. | Variant |
vcs | The vertical coordinate system (VCS). The VCS defines information about the Z coordinates. Can be set using a name, factory code, or well-known text (WKT) format. See examples below.
| Variant |
Eigenschaften
Eigenschaft | Erläuterung | Datentyp |
GCS (Nur lesen) | A projected coordinate system returns a SpatialReference object for the geographic coordinate system it is based on. A geographic coordinate system returns the same SpatialReference. | SpatialReference |
MDomain (Nur lesen) | The extent of the measure domain. | String |
MFalseOriginAndUnits (Nur lesen) | The measure false origin and units. | String |
MResolution (Lesen und schreiben) | The measure resolution. | Double |
MTolerance (Lesen und schreiben) | The measure tolerance. | Double |
VCS (Nur lesen) | If the coordinate system has a vertical coordinate system, it returns a VCS object for the vertical coordinate system it is based on. | Object |
XYResolution (Lesen und schreiben) | The xy resolution. | Double |
XYTolerance (Lesen und schreiben) | The xy tolerance. | Double |
ZDomain (Nur lesen) | The extent of the z domain. | String |
ZFalseOriginAndUnits (Nur lesen) | The z false origin and units. | String |
ZResolution (Lesen und schreiben) | The z resolution property. | Double |
ZTolerance (Lesen und schreiben) | The z-tolerance property. | Double |
abbreviation (Lesen und schreiben) | The abbreviated name of the spatial reference. | String |
alias (Lesen und schreiben) | The alias of the spatial reference. | String |
domain (Nur lesen) | The extent of the xy domain. | String |
factoryCode (Lesen und schreiben) | The factory code or well-known ID (WKID) of the spatial reference. | Integer |
falseOriginAndUnits (Nur lesen) | The false origin and units. | String |
hasMPrecision (Nur lesen) | Indicates whether m-value precision information has been defined. | Boolean |
hasXYPrecision (Nur lesen) | Indicates whether xy precision information has been defined. | Boolean |
hasZPrecision (Nur lesen) | Indicates whether z-value precision information has been defined. | Boolean |
isHighPrecision (Lesen und schreiben) | Indicates whether the spatial reference has high precision set. | Boolean |
name (Lesen und schreiben) | The name of the spatial reference. | String |
remarks (Lesen und schreiben) | The comment string of the spatial reference. | String |
type (Lesen und schreiben) | The type of the spatial reference. | String |
usage (Nur lesen) | The usage notes. | String |
PCSCode (Lesen und schreiben) | The projected coordinate system code.1 | Integer |
PCSName (Lesen und schreiben) | The projected coordinate system name.1 | String |
azimuth (Lesen und schreiben) | The azimuth of a projected coordinate system.1 | Double |
centralMeridian (Lesen und schreiben) | The central meridian of a projected coordinate system.1 | Double |
centralMeridianInDegrees (Lesen und schreiben) | The central meridian (Lambda0) of a projected coordinate system in degrees.1 | Double |
centralParallel (Lesen und schreiben) | The central parallel of a projected coordinate system.1 | Double |
classification (Nur lesen) | The classification of a map projection.1 | String |
falseEasting (Lesen und schreiben) | The false easting of a projected coordinate system.1 | Double |
falseNorthing (Lesen und schreiben) | The false northing of a projected coordinate system.1 | Double |
latitudeOf1st (Lesen und schreiben) | The latitude of the first point of a projected coordinate system.1 | Double |
latitudeOf2nd (Lesen und schreiben) | The latitude of the second point of a projected coordinate system.1 | Double |
latitudeOfOrigin (Lesen und schreiben) | The latitude of origin of a projected coordinate system.1 | Double |
linearUnitCode (Lesen und schreiben) | The linear unit code.1 | Integer |
linearUnitName (Lesen und schreiben) | The linear unit name.1 | String |
longitude (Lesen und schreiben) | The longitude value of this prime meridian.1 | Double |
longitudeOf1st (Lesen und schreiben) | The longitude of the first point of a projected coordinate system.1 | Double |
longitudeOf2nd (Lesen und schreiben) | The longitude of the second point of a projected coordinate system.1 | Double |
longitudeOfOrigin (Lesen und schreiben) | The longitude of origin of a projected coordinate system.1 | Double |
metersPerUnit (Nur lesen) | The meters per linear unit.1 | Double |
projectionCode (Lesen und schreiben) | The projection code.1 | Integer |
projectionName (Lesen und schreiben) | The projection name.1 | String |
scaleFactor (Lesen und schreiben) | The scale factor of a projected coordinate system.1 | Double |
standardParallel1 (Lesen und schreiben) | The first parallel of a projected coordinate system.1 | Double |
standardParallel2 (Lesen und schreiben) | The second parallel of a projected coordinate system.1 | Double |
GCSCode (Lesen und schreiben) | Der Code des geographischen Koordinatensystems.2 | Integer |
GCSName (Lesen und schreiben) | Der Name des geographischen Koordinatensystems.2 | String |
angularUnitCode (Lesen und schreiben) | Der Code der Winkeleinheit.2 | Integer |
angularUnitName (Lesen und schreiben) | Der Name der Winkeleinheit.2 | String |
datumCode (Lesen und schreiben) | Der Code des Datums.2 | Integer |
datumName (Lesen und schreiben) | Der Name des Datums.2 | String |
Abplattung (Lesen und schreiben) | Das Abflachungsverhältnis dieses Sphäroids.2 | Double |
Längengrad (Lesen und schreiben) | Der Längengradwert für diesen Nullmeridian.2 | Double |
primeMeridianCode (Lesen und schreiben) | Der Code des Nullmeridians.2 | Integer |
primeMeridianName (Lesen und schreiben) | Der Name des Nullmeridians.2 | String |
radiansPerUnit (Nur lesen) | Radianten pro Winkeleinheit.2 | Double |
semiMajorAxis (Lesen und schreiben) | Die Länge der großen Hauptachse dieses Sphäroids.2 | Double |
semiMinorAxis (Lesen und schreiben) | Die Länge der kleinen Hauptachse dieses Sphäroids.2 | Double |
spheroidCode (Lesen und schreiben) | Der Code des Sphäroids.2 | Integer |
spheroidName (Lesen und schreiben) | Der Name des Sphäroids.2 | String |
Methodenübersicht
Methode | Erläuterung |
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) | Sets the XY domain. |
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) | Sets the M false origin and units. |
setZDomain (z_min, z_max) | Sets the Z domain. |
setZFalseOriginAndUnits (false_z, z_units) | Sets the Z false origin and units. |
Methoden
create ()
createFromFile (prj_file)
Parameter | Erläuterung | Datentyp |
prj_file | The projection file used to populate the spatial reference object. | String |
exportToString ()
Rückgabewert
Datentyp | Erläuterung |
String | The string representation of the object. |
loadFromString (string)
Parameter | Erläuterung | Datentyp |
string | The string representation of the object. | String |
setDomain (x_min, x_max, y_min, y_max)
Parameter | Erläuterung | Datentyp |
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 |
setFalseOriginAndUnits (false_x, false_y, xy_units)
Parameter | Erläuterung | Datentyp |
false_x | The false x value. | Double |
false_y | The false y value. | Double |
xy_units | The xy units. | String |
setMDomain (m_min, m_max)
Parameter | Erläuterung | Datentyp |
m_min | The minimum m-value. | Double |
m_max | The maximum m-value. | Double |
setMFalseOriginAndUnits (false_m, m_units)
Parameter | Erläuterung | Datentyp |
false_m | The false m-value. | Double |
m_units | The m units. | Double |
setZDomain (z_min, z_max)
Parameter | Erläuterung | Datentyp |
z_min | The minimum z-value. | Double |
z_max | The maximum z-value. | Double |
setZFalseOriginAndUnits (false_z, z_units)
Parameter | Erläuterung | Datentyp |
false_z | The false z-value. | Double |
z_units | The false z units. | Double |
Codebeispiel
SpatialReference example
For each feature class in a workspace, print the name of its spatial reference.
import arcpy
# Set the workspace environment
arcpy.env.workspace = "c:/base/base.gdb"
# Get a list of the feature classes in the input folder
feature_classes = arcpy.ListFeatureClasses()
# 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))