サマリ
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.
説明
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
構文
SpatialReference ({item})
パラメータ | 説明 | データ タイプ |
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 |
latitudeOfOrigin (読み書き) | The latitude of origin 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 |
metersPerUnit (読み取り専用) | The meters per linear unit.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) | 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. |
メソッド
create ()
createFromFile (prj_file)
パラメータ | 説明 | データ タイプ |
prj_file | The projection file used to populate the spatial reference object. | String |
exportToString ()
戻り値
データ タイプ | 説明 |
String | The string representation of the object. |
loadFromString (string)
パラメータ | 説明 | データ タイプ |
string | The string representation of the object. | String |
setDomain (x_min, x_max, y_min, y_max)
パラメータ | 説明 | データ タイプ |
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)
パラメータ | 説明 | データ タイプ |
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)
パラメータ | 説明 | データ タイプ |
m_min | The minimum m-value. | Double |
m_max | The maximum m-value. | Double |
setMFalseOriginAndUnits (false_m, m_units)
パラメータ | 説明 | データ タイプ |
false_m | The false m-value. | Double |
m_units | The m units. | Double |
setZDomain (z_min, z_max)
パラメータ | 説明 | データ タイプ |
z_min | The minimum z-value. | Double |
z_max | The maximum z-value. | Double |
setZFalseOriginAndUnits (false_z, z_units)
パラメータ | 説明 | データ タイプ |
false_z | The false z-value. | Double |
z_units | The false z units. | Double |
コードのサンプル
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))