gdal.SpatialReference
This class respresents a OpenGIS Spatial Reference System, and contains methods for converting between this object organization and well known text (WKT) format.
Table of Contents
-
Methods
- autoIdentifyEPSG()
- clone()
- cloneGeogCS()
- EPSGTreatsAsLatLong()
- EPSGTreatsAsNorthingEasting()
- getAngularUnits()
- getAttrValue(node_nameattr_index)
- getAuthorityCode(target_key)
- getAuthorityName(target_key)
- getLinearUnits()
- isCompound()
- isGeocentric()
- isGeographic()
- isLocal()
- isProjected()
- isSame(srs)
- isSameGeogCS(srs)
- isSameVertCS(srs)
- isVertical()
- morphFromESRI()
- morphToESRI()
- setWellKnownGeogCS(name)
- toPrettyWKT(simplify)
- toProj4()
- toWKT()
- toXML()
- validate()
-
Static Methods
- gdal.SpatialReference.fromCRSURL(input)
- gdal.SpatialReference.fromEPSG(input)
- gdal.SpatialReference.fromEPSGA(input)
- gdal.SpatialReference.fromESRI(input)
- gdal.SpatialReference.fromMICoordSys(input)
- gdal.SpatialReference.fromProj4(input)
- gdal.SpatialReference.fromURL(url)
- gdal.SpatialReference.fromURN(input)
- gdal.SpatialReference.fromUserInput(input)
- gdal.SpatialReference.fromWKT(wkt)
- gdal.SpatialReference.fromWMSAUTO(input)
- gdal.SpatialReference.fromXML(input)
Constructor
gdal.SpatialReference
-
wkt
Parameters:
-
[wkt]
String optional
Methods
autoIdentifyEPSG
()
Set EPSG authority info if possible.
Make a duplicate of the GEOGCS node of this OGRSpatialReference object.
Returns:
EPSGTreatsAsLatLong
()
Boolean
This method returns true
if EPSG feels this geographic coordinate system
should be treated as having lat/long coordinate ordering.
Currently this returns true
for all geographic coordinate systems with an
EPSG code set, and AXIS values set defining it as lat, long. Note that
coordinate systems with an EPSG code and no axis settings will be assumed
to not be lat/long.
false
will be returned for all coordinate systems that are not geographic,
or that do not have an EPSG code set.
Returns:
EPSGTreatsAsNorthingEasting
()
Boolean
This method returns true
if EPSG feels this projected coordinate system
should be treated as having northing/easting coordinate ordering.
Returns:
getAngularUnits
()
Object
Fetch angular geographic coordinate system units.
Returns:
An object containing value
and unit
properties.
getAttrValue
-
node_name
-
attr_index=0
Fetch indicated attribute of named node.
Parameters:
-
node_name
String -
[attr_index=0]
Integer optional
Returns:
getAuthorityCode
-
target_key
Get the authority code for a node.
Parameters:
-
target_key
StringThe partial or complete path to the node to get an authority from. ie.
"PROJCS"
,"GEOGCS"
, "GEOGCS|UNIT"
ornull
to search for an authority node on the root element.
Returns:
getAuthorityName
-
target_key
Get the authority name for a node. The most common authority is "EPSG".
Parameters:
-
target_key
StringThe partial or complete path to the node to get an authority from. ie.
"PROJCS"
,"GEOGCS"
, "GEOGCS|UNIT"
ornull
to search for an authority node on the root element.
Returns:
getLinearUnits
()
Object
Fetch linear geographic coordinate system units.
Returns:
An object containing value
and unit
properties.
isCompound
()
Boolean
Check if compound coordinate system.
Returns:
isGeocentric
()
Boolean
Check if geocentric coordinate system.
Returns:
isGeographic
()
Boolean
Check if geographic coordinate system.
Returns:
isLocal
()
Boolean
Check if local coordinate system.
Returns:
isProjected
()
Boolean
Check if projected coordinate system.
Returns:
isSame
-
srs
Do these two spatial references describe the same system?
Parameters:
Returns:
isSameGeogCS
-
srs
Do the GeogCS'es match?
Parameters:
Returns:
isSameVertCS
-
srs
Do the VertCS'es match?
Parameters:
Returns:
isVertical
()
Boolean
Check if vertical coordinate system.
Returns:
morphFromESRI
()
Convert in place from ESRI WKT format.
morphToESRI
()
Convert in place to ESRI WKT format.
setWellKnownGeogCS
-
name
Set a GeogCS based on well known name.
Parameters:
-
name
String
toPrettyWKT
-
simplify=false
Convert this SRS into a a nicely formatted WKT string for display to a person.
Parameters:
-
[simplify=false]
Boolean optional
Returns:
toProj4
()
String
Export coordinate system in PROJ.4 format.
Returns:
toWKT
()
String
Convert this SRS into WKT format.
Returns:
toXML
()
String
Export coordinate system in XML format.
Returns:
validate
()
String | Null
Validate SRS tokens.
This method attempts to verify that the spatial reference system is well formed, and consists of known tokens. The validation is not comprehensive.
Returns:
"corrupt"
, '"unsupported"', null
(if fine)
Static Methods
Initialize from OGC URL.
The OGC URL should be prefixed with "http://opengis.net/def/crs" per best practice paper 11-135. Currently EPSG and OGC authority values are supported, including OGC auto codes, but not including CRS1 or CRS88 (NAVD88).
Parameters:
-
input
String
Returns:
Initialize from EPSG GCS or PCS code.
Parameters:
-
input
String
Returns:
Example:
var ref = gdal.SpatialReference.fromEPSGA(4326);`
Initialize from EPSG GCS or PCS code.
This method is similar to fromEPSG()
except that EPSG preferred axis
ordering will be applied for geographic and projected coordinate systems.
EPSG normally defines geographic coordinate systems to use lat/long, and also
there are also a few projected coordinate systems that use northing/easting
order contrary to typical GIS use).
Parameters:
-
input
Integer
Returns:
Example:
var ref = gdal.SpatialReference.fromEPSGA(26910);`
Import coordinate system from ESRI .prj format(s).
This function will read the text loaded from an ESRI .prj file, and translate it into an OGRSpatialReference definition. This should support many (but by no means all) old style (Arc/Info 7.x) .prj files, as well as the newer pseudo-OGC WKT .prj files. Note that new style .prj files are in OGC WKT format, but require some manipulation to correct datum names, and units on some projection parameters. This is addressed within importFromESRI() by an automatical call to morphFromESRI().
Currently only GEOGRAPHIC, UTM, STATEPLANE, GREATBRITIAN_GRID, ALBERS, EQUIDISTANT_CONIC, TRANSVERSE (mercator), POLAR, MERCATOR and POLYCONIC projections are supported from old style files.
Parameters:
-
input
String[]
Returns:
Initialize from a Mapinfo style CoordSys definition.
Parameters:
-
input
String
Returns:
Creates a spatial reference from a Proj.4 string.
Parameters:
-
input
String
Returns:
Initialize spatial reference from a URL.
This method will download the spatial reference from the given URL.
Parameters:
-
url
String
Returns:
Initialize from OGC URN.
The OGC URN should be prefixed with "urn:ogc:def:crs:" per recommendation paper 06-023r1. Currently EPSG and OGC authority values are supported, including OGC auto codes, but not including CRS1 or CRS88 (NAVD88).
Parameters:
-
input
String
Returns:
Initialize from an arbitrary spatial reference string.
This method will examine the provided input, and try to deduce the format, and then use it to initialize the spatial reference system.
Parameters:
-
input
String
Returns:
Creates a spatial reference from a WKT string.
Parameters:
-
wkt
String
Returns:
Creates a spatial reference from a WMSAUTO string.
Note that the WMS 1.3 specification does not include the units code, while apparently earlier specs do. GDAL tries to guess around this.
Parameters:
-
input
String
Returns:
Example:
var wms = 'AUTO:42001,99,8888';
var ref = gdal.SpatialReference.fromWMSAUTO(wms);`
Import coordinate system from XML format (GML only currently).
Parameters:
-
input
String