class documentation

class SpatialReference(GDALBase):

View In Hierarchy

A wrapper for the OGRSpatialReference object. According to the GDAL web site, the SpatialReference object "provide[s] services to represent coordinate systems (projections and datums) and to transform between them."
Method __getitem__ Return the value of the given string attribute node, None if the node doesn't exist. Can also take a tuple as a parameter, (target, child), where child is the index of the attribute in the WKT. For example:
Method attr​_value The attribute value for the given target node (e.g. 'PROJCS'). The index keyword specifies an index of the child node to return.
Method auth​_code Return the authority code for the given string target node.
Method auth​_name Return the authority name for the given string target node.
Method clone Return a clone of this SpatialReference object.
Method from​_esri Morph this SpatialReference from ESRI's format to EPSG.
Method identify​_epsg This method inspects the WKT of this SpatialReference, and will add EPSG authority nodes where an EPSG identifier is applicable.
Method import​_epsg Import the Spatial Reference from the EPSG code (an integer).
Method import​_proj Import the Spatial Reference from a PROJ string.
Method import​_user​_input Import the Spatial Reference from the given user input string.
Method import​_wkt Import the Spatial Reference from OGC WKT (string)
Method import​_xml Import the Spatial Reference from an XML string.
Method to​_esri Morph this SpatialReference to ESRI's format.
Method validate Check to see if the given spatial reference is valid.
Method __init__ No summary
Method __str__ Use 'pretty' WKT.
Instance Variable axis​_order Undocumented
Instance Variable ptr Undocumented
Property angular​_name Return the name of the angular units.
Property angular​_units Return the value of the angular units.
Property ellipsoid Return a tuple of the ellipsoid parameters: (semimajor axis, semiminor axis, and inverse flattening)
Property geographic Return True if this SpatialReference is geographic (root node is GEOGCS).
Property inverse​_flattening Return the Inverse Flattening for this Spatial Reference.
Property linear​_name Return the name of the linear units.
Property linear​_units Return the value of the linear units.
Property local Return True if this SpatialReference is local (root node is LOCAL_CS).
Property name Return the name of this Spatial Reference.
Property pretty​_wkt Return the 'pretty' representation of the WKT.
Property proj Return the PROJ representation for this Spatial Reference.
Property proj4 Alias for proj().
Property projected Return True if this SpatialReference is a projected coordinate system (root node is PROJCS).
Property semi​_major Return the Semi Major Axis for this Spatial Reference.
Property semi​_minor Return the Semi Minor Axis for this Spatial Reference.
Property srid Return the SRID of top-level authority, or None if undefined.
Property units Return a 2-tuple of the units value and the units name. Automatically determine whether to return the linear or angular units.
Property wkt Return the WKT representation of this Spatial Reference.
Property xml Return the XML representation of this Spatial Reference.

Inherited from CPointerBase (via GDALBase):

Method __del__ Free the memory used by the C++ object.
Method ptr.setter Undocumented
Class Variable destructor Undocumented
Instance Variable ​_ptr Undocumented
def __getitem__(self, target):

Return the value of the given string attribute node, None if the node doesn't exist. Can also take a tuple as a parameter, (target, child), where child is the index of the attribute in the WKT. For example:

>>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]'
>>> srs = SpatialReference(wkt) # could also use 'WGS84', or 4326
>>> print(srs['GEOGCS'])
WGS 84
>>> print(srs['DATUM'])
WGS_1984
>>> print(srs['AUTHORITY'])
EPSG
>>> print(srs['AUTHORITY', 1]) # The authority value
4326
>>> print(srs['TOWGS84', 4]) # the fourth value in this wkt
0
>>> print(srs['UNIT|AUTHORITY']) # For the units authority, have to use the pipe symbole.
EPSG
>>> print(srs['UNIT|AUTHORITY', 1]) # The authority value for the units
9122
def attr_value(self, target, index=0):
The attribute value for the given target node (e.g. 'PROJCS'). The index keyword specifies an index of the child node to return.
def auth_code(self, target):
Return the authority code for the given string target node.
def auth_name(self, target):
Return the authority name for the given string target node.
def clone(self):
Return a clone of this SpatialReference object.
def from_esri(self):
Morph this SpatialReference from ESRI's format to EPSG.
def identify_epsg(self):
This method inspects the WKT of this SpatialReference, and will add EPSG authority nodes where an EPSG identifier is applicable.
def import_epsg(self, epsg):
Import the Spatial Reference from the EPSG code (an integer).
def import_proj(self, proj):
Import the Spatial Reference from a PROJ string.
def import_user_input(self, user_input):
Import the Spatial Reference from the given user input string.
def import_wkt(self, wkt):
Import the Spatial Reference from OGC WKT (string)
def import_xml(self, xml):
Import the Spatial Reference from an XML string.
def to_esri(self):
Morph this SpatialReference to ESRI's format.
def validate(self):
Check to see if the given spatial reference is valid.
def __init__(self, srs_input='', srs_type='user', axis_order=None):
Create a GDAL OSR Spatial Reference object from the given input. The input may be string of OGC Well Known Text (WKT), an integer EPSG code, a PROJ string, and/or a projection "well known" shorthand string (one of 'WGS84', 'WGS72', 'NAD27', 'NAD83').
def __str__(self):
Use 'pretty' WKT.
axis_order =

Undocumented

ptr =
@property
angular_name =
Return the name of the angular units.
@property
angular_units =
Return the value of the angular units.
@property
ellipsoid =
Return a tuple of the ellipsoid parameters:
(semimajor axis, semiminor axis, and inverse flattening)
@property
geographic =
Return True if this SpatialReference is geographic
(root node is GEOGCS).
@property
inverse_flattening =
Return the Inverse Flattening for this Spatial Reference.
@property
linear_name =
Return the name of the linear units.
@property
linear_units =
Return the value of the linear units.
@property
local =
Return True if this SpatialReference is local (root node is LOCAL_CS).
@property
name =
Return the name of this Spatial Reference.
@property
pretty_wkt =
Return the 'pretty' representation of the WKT.
@property
proj =
Return the PROJ representation for this Spatial Reference.
@property
proj4 =
Alias for proj().
@property
projected =
Return True if this SpatialReference is a projected coordinate system
(root node is PROJCS).
@property
semi_major =
Return the Semi Major Axis for this Spatial Reference.
@property
semi_minor =
Return the Semi Minor Axis for this Spatial Reference.
@property
srid =
Return the SRID of top-level authority, or None if undefined.
@property
units =
Return a 2-tuple of the units value and the units name. Automatically determine whether to return the linear or angular units.
@property
wkt =
Return the WKT representation of this Spatial Reference.
@property
xml =
Return the XML representation of this Spatial Reference.