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."
Attributes
| Attribute | Type | Description |
|---|
| destructor | callable = capi.release_srs | The C API function used to release the OGRSpatialReference object when the instance is destroyed. |
| axis_order | [AxisOrder](axisorder.md?sid=django_contrib_gis_gdal_srs_axisorder) = AxisOrder.TRADITIONAL | The strategy used for coordinate axis ordering, which must be an AxisOrder instance. |
| ptr | pointer | The internal pointer to the underlying OGRSpatialReference C object. |
| name | string | Return the name of this Spatial Reference. |
| srid | integer | Return the SRID of top-level authority, or None if undefined. |
| linear_name | string | Return the name of the linear units. |
| linear_units | float | Return the value of the linear units. |
| angular_name | string | Return the name of the angular units. |
| angular_units | float | Return the value of the angular units. |
| units | tuple | Return a 2-tuple of the units value and the units name. |
| ellipsoid | tuple | Return a tuple of the ellipsoid parameters: (semimajor axis, semiminor axis, and inverse flattening). |
| semi_major | float | Return the Semi Major Axis for this Spatial Reference. |
| semi_minor | float | Return the Semi Minor Axis for this Spatial Reference. |
| inverse_flattening | float | Return the Inverse Flattening for this Spatial Reference. |
| geographic | boolean | Return True if this SpatialReference is geographic (root node is GEOGCS). |
| local | boolean | Return True if this SpatialReference is local (root node is LOCAL_CS). |
| projected | boolean | Return True if this SpatialReference is a projected coordinate system (root node is PROJCS). |
| wkt | string | Return the WKT representation of this Spatial Reference. |
| pretty_wkt | string | Return the 'pretty' representation of the WKT. |
| proj | string | Return the PROJ representation for this Spatial Reference. |
| proj4 | string | Alias for proj(). |
| xml | string | Return the XML representation of this Spatial Reference. |
Constructor
Signature
def SpatialReference(
srs_input: string|int = "",
srs_type: string = "user",
axis_order: [AxisOrder](axisorder.md?sid=django_contrib_gis_gdal_srs_axisorder) = null
) - > null
Parameters
| Name | Type | Description |
|---|
| srs_input | `string | int` = "" |
| srs_type | string = "user" | The type of the input provided in srs_input (e.g., 'user', 'wkt', 'epsg'). |
| axis_order | [AxisOrder](axisorder.md?sid=django_contrib_gis_gdal_srs_axisorder) = null | The axis order strategy to be used by the spatial reference. |
Methods
attr_value()
@classmethod
def attr_value(
target: string,
index: integer = 0
) - > string
The attribute value for the given target node (e.g. 'PROJCS'). The index keyword specifies an index of the child node to return.
Parameters
| Name | Type | Description |
|---|
| target | string | The name of the WKT node to query. |
| index | integer = 0 | The zero-based index of the child node to retrieve. |
Returns
| Type | Description |
|---|
string | The string value of the specified attribute node. |
auth_name()
@classmethod
def auth_name(
target: string
) - > string
Return the authority name for the given string target node.
Parameters
| Name | Type | Description |
|---|
| target | string | The WKT node name for which to retrieve the authority name. |
Returns
| Type | Description |
|---|
string | The name of the authority (e.g., 'EPSG') for the specified node. |
auth_code()
@classmethod
def auth_code(
target: string
) - > string
Return the authority code for the given string target node.
Parameters
| Name | Type | Description |
|---|
| target | string | The WKT node name for which to retrieve the authority code. |
Returns
| Type | Description |
|---|
string | The authority's identification code (e.g., '4326') for the specified node. |
clone()
@classmethod
def clone() - > [SpatialReference](spatialreference.md?sid=django_contrib_gis_gdal_srs_spatialreference)
Return a clone of this SpatialReference object.
Returns
| Type | Description |
|---|
[SpatialReference](spatialreference.md?sid=django_contrib_gis_gdal_srs_spatialreference) | A new SpatialReference instance that is a duplicate of the current one. |
from_esri()
@classmethod
def from_esri()
Morph this SpatialReference from ESRI's format to EPSG.
identify_epsg()
@classmethod
def identify_epsg()
This method inspects the WKT of this SpatialReference, and will add EPSG authority nodes where an EPSG identifier is applicable.
to_esri()
@classmethod
def to_esri()
Morph this SpatialReference to ESRI's format.
validate()
@classmethod
def validate()
Check to see if the given spatial reference is valid.
name()
@classmethod
def name() - > string
Return the name of this Spatial Reference.
Returns
| Type | Description |
|---|
string | The name of the coordinate system (e.g., PROJCS or GEOGCS value). |
srid()
@classmethod
def srid() - > integer
Return the SRID of top-level authority, or None if undefined.
Returns
| Type | Description |
|---|
integer | The integer Spatial Reference Identifier or None. |
linear_name()
@classmethod
def linear_name() - > string
Return the name of the linear units.
Returns
| Type | Description |
|---|
string | The name of the linear unit of measure (e.g., 'metre'). |
linear_units()
@classmethod
def linear_units() - > float
Return the value of the linear units.
Returns
| Type | Description |
|---|
float | The conversion factor from the linear unit to meters. |
angular_name()
@classmethod
def angular_name() - > string
Return the name of the angular units.
Returns
| Type | Description |
|---|
string | The name of the angular unit of measure (e.g., 'degree'). |
angular_units()
@classmethod
def angular_units() - > float
Return the value of the angular units.
Returns
| Type | Description |
|---|
float | The conversion factor from the angular unit to radians. |
units()
@classmethod
def units() - > tuple
Return a 2-tuple of the units value and the units name. Automatically determine whether to return the linear or angular units.
Returns
| Type | Description |
|---|
tuple | A tuple containing the unit conversion factor and the unit name string. |
ellipsoid()
@classmethod
def ellipsoid() - > tuple
Return a tuple of the ellipsoid parameters: (semimajor axis, semiminor axis, and inverse flattening)
Returns
| Type | Description |
|---|
tuple | A 3-tuple containing the semi-major axis, semi-minor axis, and inverse flattening values. |
semi_major()
@classmethod
def semi_major() - > float
Return the Semi Major Axis for this Spatial Reference.
Returns
| Type | Description |
|---|
float | The length of the semi-major axis of the ellipsoid. |
semi_minor()
@classmethod
def semi_minor() - > float
Return the Semi Minor Axis for this Spatial Reference.
Returns
| Type | Description |
|---|
float | The length of the semi-minor axis of the ellipsoid. |
inverse_flattening()
@classmethod
def inverse_flattening() - > float
Return the Inverse Flattening for this Spatial Reference.
Returns
| Type | Description |
|---|
float | The inverse flattening value of the ellipsoid. |
geographic()
@classmethod
def geographic() - > boolean
Return True if this SpatialReference is geographic (root node is GEOGCS).
Returns
| Type | Description |
|---|
boolean | True if the spatial reference is geographic, False otherwise. |
local()
@classmethod
def local() - > boolean
Return True if this SpatialReference is local (root node is LOCAL_CS).
Returns
| Type | Description |
|---|
boolean | True if the spatial reference is a local coordinate system, False otherwise. |
projected()
@classmethod
def projected() - > boolean
Return True if this SpatialReference is a projected coordinate system (root node is PROJCS).
Returns
| Type | Description |
|---|
boolean | True if the spatial reference is projected, False otherwise. |
import_epsg()
@classmethod
def import_epsg(
epsg: integer
)
Import the Spatial Reference from the EPSG code (an integer).
Parameters
| Name | Type | Description |
|---|
| epsg | integer | The EPSG numeric code representing the coordinate system. |
import_proj()
@classmethod
def import_proj(
proj: string
)
Import the Spatial Reference from a PROJ string.
Parameters
| Name | Type | Description |
|---|
| proj | string | The PROJ projection string defining the spatial reference. |
@classmethod
def import_user_input(
user_input: string
)
Import the Spatial Reference from the given user input string.
Parameters
| Name | Type | Description |
|---|
| user_input | string | A string containing WKT, PROJ, or a well-known shorthand like 'WGS84'. |
import_wkt()
@classmethod
def import_wkt(
wkt: string
)
Import the Spatial Reference from OGC WKT (string)
Parameters
| Name | Type | Description |
|---|
| wkt | string | The OGC Well Known Text string to parse. |
import_xml()
@classmethod
def import_xml(
xml: string
)
Import the Spatial Reference from an XML string.
Parameters
| Name | Type | Description |
|---|
| xml | string | The XML string containing the spatial reference definition. |
wkt()
@classmethod
def wkt() - > string
Return the WKT representation of this Spatial Reference.
Returns
| Type | Description |
|---|
string | The OGC Well Known Text string for this spatial reference. |
pretty_wkt()
@classmethod
def pretty_wkt(
simplify: integer = 0
) - > string
Return the 'pretty' representation of the WKT.
Parameters
| Name | Type | Description |
|---|
| simplify | integer = 0 | A flag indicating whether to simplify the output WKT. |
Returns
| Type | Description |
|---|
string | A formatted, multi-line Well Known Text string. |
proj()
@classmethod
def proj() - > string
Return the PROJ representation for this Spatial Reference.
Returns
| Type | Description |
|---|
string | The PROJ string representation of the coordinate system. |
proj4()
@classmethod
def proj4() - > string
Alias for proj().
Returns
| Type | Description |
|---|
string | The PROJ string representation of the coordinate system. |
xml()
@classmethod
def xml(
dialect: string = ""
) - > string
Return the XML representation of this Spatial Reference.
Parameters
| Name | Type | Description |
|---|
| dialect | string = "" | The specific XML dialect to use for the output. |
Returns
| Type | Description |
|---|
string | The XML string representation of the spatial reference. |