Show:

This class respresents a OpenGIS Spatial Reference System, and contains methods for converting between this object organization and well known text (WKT) format.

Constructor

gdal.SpatialReference
(
  • wkt
)

Parameters:

  • [wkt] String optional

Methods

autoIdentifyEPSG ()

Set EPSG authority info if possible.

Clones the spatial reference.

cloneGeogCS () gdal.SpatialReference

Make a duplicate of the GEOGCS node of this OGRSpatialReference object.

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:

Boolean
EPSGTreatsAsNorthingEasting () Boolean

This method returns true if EPSG feels this projected coordinate system should be treated as having northing/easting coordinate ordering.

Returns:

Boolean
getAngularUnits () Object

Fetch angular geographic coordinate system units.

Returns:

Object:

An object containing value and unit properties.

getAttrValue
(
  • node_name
  • attr_index=0
)
String

Fetch indicated attribute of named node.

Parameters:

  • node_name String
  • [attr_index=0] Integer optional

Returns:

String
getAuthorityCode
(
  • target_key
)
String

Get the authority code for a node.

Parameters:

  • target_key String

    The partial or complete path to the node to get an authority from. ie. "PROJCS", "GEOGCS", "GEOGCS|UNIT" or null to search for an authority node on the root element.

Returns:

String
getAuthorityName
(
  • target_key
)
String

Get the authority name for a node. The most common authority is "EPSG".

Parameters:

  • target_key String

    The partial or complete path to the node to get an authority from. ie. "PROJCS", "GEOGCS", "GEOGCS|UNIT" or null to search for an authority node on the root element.

Returns:

String
getLinearUnits () Object

Fetch linear geographic coordinate system units.

Returns:

Object:

An object containing value and unit properties.

isCompound () Boolean

Check if compound coordinate system.

Returns:

Boolean
isGeocentric () Boolean

Check if geocentric coordinate system.

Returns:

Boolean
isGeographic () Boolean

Check if geographic coordinate system.

Returns:

Boolean
isLocal () Boolean

Check if local coordinate system.

Returns:

Boolean
isProjected () Boolean

Check if projected coordinate system.

Returns:

Boolean
isSame
(
  • srs
)
Boolean

Do these two spatial references describe the same system?

Parameters:

Returns:

Boolean
isSameGeogCS
(
  • srs
)
Boolean

Do the GeogCS'es match?

Parameters:

Returns:

Boolean
isSameVertCS
(
  • srs
)
Boolean

Do the VertCS'es match?

Parameters:

Returns:

Boolean
isVertical () Boolean

Check if vertical coordinate system.

Returns:

Boolean
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
)
String

Convert this SRS into a a nicely formatted WKT string for display to a person.

Parameters:

  • [simplify=false] Boolean optional

Returns:

String
toProj4 () String

Export coordinate system in PROJ.4 format.

Returns:

String
toWKT () String

Convert this SRS into WKT format.

Returns:

String
toXML () String

Export coordinate system in XML format.

Returns:

String
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:

String | Null:

"corrupt", '"unsupported"', null (if fine)

Static Methods

gdal.SpatialReference.fromCRSURL
(
  • input
)
gdal.SpatialReference

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
gdal.SpatialReference.fromEPSG
(
  • input
)
gdal.SpatialReference

Initialize from EPSG GCS or PCS code.

Parameters:

  • input String

Example:

var ref = gdal.SpatialReference.fromEPSGA(4326);`
gdal.SpatialReference.fromEPSGA
(
  • input
)
gdal.SpatialReference

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

Example:

var ref = gdal.SpatialReference.fromEPSGA(26910);`
gdal.SpatialReference.fromESRI
(
  • input
)
gdal.SpatialReference

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[]
gdal.SpatialReference.fromMICoordSys
(
  • input
)
gdal.SpatialReference

Initialize from a Mapinfo style CoordSys definition.

Parameters:

  • input String
gdal.SpatialReference.fromProj4
(
  • input
)
gdal.SpatialReference

Creates a spatial reference from a Proj.4 string.

Parameters:

  • input String
gdal.SpatialReference.fromURL
(
  • url
)
gdal.SpatialReference

Initialize spatial reference from a URL.

This method will download the spatial reference from the given URL.

Parameters:

  • url String
gdal.SpatialReference.fromURN
(
  • input
)
gdal.SpatialReference

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
gdal.SpatialReference.fromUserInput
(
  • input
)
gdal.SpatialReference

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
gdal.SpatialReference.fromWKT
(
  • wkt
)
gdal.SpatialReference

Creates a spatial reference from a WKT string.

Parameters:

  • wkt String
gdal.SpatialReference.fromWMSAUTO
(
  • input
)
gdal.SpatialReference

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

Example:

var wms = 'AUTO:42001,99,8888';
var ref = gdal.SpatialReference.fromWMSAUTO(wms);`
gdal.SpatialReference.fromXML
(
  • input
)
gdal.SpatialReference

Import coordinate system from XML format (GML only currently).

Parameters:

  • input String