Spatial Reference System API
This page contains classes, methods and functions that relate to spatial reference systems:
SpatialReference
- class osgeo.osr.SpatialReference(*args, **kwargs)
Python proxy of an
OGRSpatialReference.Create a new spatial reference object. An empty object will be created unless exactly one of the following parameters is provided.
- Parameters:
name (str or dict, optional) -- SRS description in a format understood by
SetFromUserInput().epsg (int, optional) -- EPSG CRS code, as understood by
ImportFromEPSG()wkt (str, optional) -- WKT CRS string, as understood by
ImportFromWkt()
Examples
>>> osr.SpatialReference(epsg=5646).GetName() 'NAD83 / Vermont (ftUS)' >>> osr.SpatialReference('+proj=utm +zone=18 +datum=WGS84').GetUTMZone() 18
- AddGuessedTOWGS84(self) OGRErr
- AutoIdentifyEPSG(self) OGRErr
Add an EPSG authority code to the CRS where an aspect of the coordinate system can be easily and safely corresponded with an EPSG identifier.
See
OGRSpatialReference::AutoIdentifyEPSG().- Returns:
OGRERR_NONEorOGRERR_UNSUPPORTED_SRS.- Return type:
int
- Clone(self) SpatialReference
- CloneGeogCS(self) SpatialReference
- ConvertToOtherProjection(self, other_projection, options=None) SpatialReference
- CopyGeogCSFrom(self, rhs) OGRErr
- DemoteTo2D(self, name=None) OGRErr
- EPSGTreatsAsLatLong(self) int
- EPSGTreatsAsNorthingEasting(self) int
- ExportToCF1(options={})
Export a CRS to netCDF CF-1 definitions.
http://cfconventions.org/cf-conventions/cf-conventions.html#appendix-grid-mappings
- ExportToCF1Units(self, options=None) retStringAndCPLFree *
- ExportToERM(self) OGRErr
- ExportToMICoordSys(self) OGRErr
- ExportToPCI(self) OGRErr
- ExportToPROJJSON(self, options=None) OGRErr
Export this SRS in PROJJSON format.
See
OGRSpatialReference::exportToPROJJSON().- Parameters:
options (list or dict) -- Options to control the format of the output. See
OGRSpatialReference::exportToPROJJSON().- Return type:
str
- ExportToPrettyWkt(self, simplify=0) OGRErr
Convert this SRS into a nicely formatted WKT 1 string for display to a person.
See
OGRSpatialReference::exportToPrettyWkt().- Parameters:
simplify (bool, default = False)
- Return type:
str
- ExportToProj4(self) OGRErr
Export this SRS to PROJ.4 legacy format.
Warning
Use of this function is discouraged. See
OGRSpatialReference::exportToProj4().- Return type:
str
- ExportToUSGS(self) OGRErr
- ExportToWkt(self, options=None) OGRErr
Export this SRS into WKT 1 format.
See
OGRSpatialReference::exportToWkt().- Return type:
str
See also
- ExportToXML(self, dialect='') OGRErr
- FindMatches(self, options=None)
- GetAngularUnits(self) double
Fetch conversion between angular geographic coordinate system units and radians.
See
OGRSpatialReference::GetAngularUnits().- Returns:
Value to multiply angular distances by to transform them to radians.
- Return type:
float
Examples
>>> srs = osr.SpatialReference() >>> srs.ImportFromEPSG(4326) 0 >>> srs.GetAngularUnits() 0.017453292519943295
- GetAngularUnitsName(self) char const *
Fetch angular geographic coordinate system units.
See
OGRSpatialReference::GetAngularUnits().- Return type:
str
Examples
>>> srs = osr.SpatialReference() >>> srs.ImportFromEPSG(4326) 0 >>> srs.GetAngularUnitsName() 'degree'
- GetAreaOfUse(self) AreaOfUse
Return the area of use of the SRS.
See
OGRSpatialReference::GetAreaOfUse().- Returns:
object providing a description of the area of use as well as bounding parallels / meridians
- Return type:
Examples
>>> vt_sp = osr.SpatialReference() >>> vt_sp.ImportFromEPSG(5646) 0 >>> aou = vt_sp.GetAreaOfUse() >>> aou.name 'United States (USA) - Vermont - counties of Addison; Bennington; Caledonia; Chittenden; Essex; Franklin; Grand Isle; Lamoille; Orange; Orleans; Rutland; Washington; Windham; Windsor.' >>> aou.west_lon_degree, aou.south_lat_degree, aou.east_lon_degree, aou.north_lat_degree (-73.44, 42.72, -71.5, 45.03)
- GetAttrValue(self, name, child=0) char const *
Fetch indicated attribute of named node.
See
OGRSpatialReference::GetAttrValue().- Parameters:
name (str) -- tree node to look for (case insensitive)
child (int, default = 0) -- 0-indexed child of the node
- Return type:
str
Examples
>>> vt_sp = osr.SpatialReference() >>> vt_sp.ImportFromEPSG(5646) 0 >>> vt_sp.GetAttrValue('UNIT', 0) 'US survey foot'
- GetAuthorityCode(self, target_key=None) char const *
Get the authority code for a node.
See
OGRSpatialReference::GetAuthorityCode().- Parameters:
target_key (str) -- the partial or complete path to the node to get an authority from (e.g., 'PROJCS', 'GEOGCS' or
Noneto get an authority code on the root element)- Returns:
Returns a string on success or
Noneon failure.- Return type:
str or None
Examples
>>> srs = osr.SpatialReference() >>> srs.ImportFromEPSG(4326) 0 >>> srs.GetAuthorityName('DATUM') 'EPSG' >>> srs.GetAuthorityCode('DATUM') '6326' >>> srs.GetAuthorityCode(None) '4326'
- GetAuthorityName(self, target_key=None) char const *
Get the authority name for a node.
See
OGRSpatialReference::GetAuthorityName().- Parameters:
target_key (str) -- the partial or complete path to the node to get an authority from (e.g., 'PROJCS', 'GEOGCS' or
Noneto get an authority name on the root element)- Return type:
str
- GetAxesCount(self) int
Return the number of axes of the coordinate system of the CRS.
See
OGRSpatialReference::GetAxesCount().- Return type:
int
Examples
>>> srs = osr.SpatialReference() >>> srs.ImportFromEPSG(4326) 0 >>> srs.GetAxesCount() 2 >>> srs.ImportFromEPSG(4979) 0 >>> srs.GetAxesCount() 3
- GetAxisMappingStrategy(self) OSRAxisMappingStrategy
Return the data axis to CRS axis mapping strategy:
OAMS_TRADITIONAL_GIS_ORDERmeans that for geographic CRS with lag/long order, the data will still be long/lat ordered. Similarly for a projected CRS with northing/easting order, the data will still be easting/northing ordered.OAMS_AUTHORITY_COMPLIANTmeans that the data axis will be identical to the CRS axis.OAMS_CUSTOMmeans that the ordering is defined withSetDataAxisToSRSAxisMapping().
See
OGRSpatialReference::GetAxisMappingStrategy().- Return type:
int
- GetAxisName(self, target_key, iAxis) char const *
Fetch an axis description.
See
OGRSpatialReference::GetAxis().- Parameters:
target_key (str) -- The portion of the coordinate system, either 'GEOGCS' or 'PROJCS'
iAxis (int) -- The 0-based index of the axis to fetch
- Return type:
str
Examples
>>> srs = osr.SpatialReference() >>> srs.ImportFromEPSG(4979) 0 >>> for i in range(3): ... srs.GetAxisName('GEOGCS', i) ... 'Geodetic latitude' 'Geodetic longitude' 'Ellipsoidal height'
- GetAxisOrientation(self, target_key, iAxis) OGRAxisOrientation
Fetch an axis orientation.
See
OGRSpatialReference::GetAxis().- Parameters:
target_key (str) -- The portion of the coordinate system, either 'GEOGCS' or 'PROJCS'
iAxis (int) -- The 0-based index of the axis to fetch
- Return type:
int
Examples
>>> srs = osr.SpatialReference() >>> srs.ImportFromEPSG(4979) 0 >>> srs.GetAxisOrientation('GEOGCS', 0) == osr.OAO_North True >>> srs.GetAxisOrientation('GEOGCS', 1) == osr.OAO_East True >>> srs.GetAxisOrientation('GEOGCS', 2) == osr.OAO_Up True
- GetCelestialBodyName(self) char const *
- GetCoordinateEpoch(self) double
Return the coordinate epoch as a decimal year.
See
OGRSpatialReference::GetCoordinateEpoch().- Returns:
coordinate epoch as a decimal year, or 0 if not set/relevant
- Return type:
float
- GetDataAxisToSRSAxisMapping(self)
Return the data axis to SRS axis mapping.
See
OGRSpatialReference::GetDataAxisToSRSAxisMapping().- Return type:
tuple
- GetInvFlattening(self) double
Get the spheroid inverse flattening.
See
OGRSpatialReference::GetInvFlattening().- Return type:
float
Examples
>>> srs = osr.SpatialReference() >>> srs.ImportFromEPSG(4326) # WGS84 0 >>> srs.GetInvFlattening() 298.257223563 >>> srs.ImportFromEPSG(4269) # NAD83 0 >>> srs.GetInvFlattening() 298.257222101
- GetLinearUnits(self) double
Fetch the conversion between linear projection units and meters.
See
OGRSpatialReference::GetLinearUnits().- Return type:
float
Examples
>>> vt_sp = osr.SpatialReference() >>> vt_sp.ImportFromEPSG(5646) 0 >>> vt_sp.GetLinearUnits() 0.30480060960121924
- GetLinearUnitsName(self) char const *
Fetch the name of the linear projection units.
See
OGRSpatialReference::GetLinearUnits().- Return type:
str
Examples
>>> vt_sp = osr.SpatialReference() >>> vt_sp.ImportFromEPSG(5646) 0 >>> vt_sp.GetLinearUnitsName() 'US survey foot'
- GetName(self) char const *
Return the CRS name.
See
OGRSpatialReference::GetName().- Return type:
str
Examples
>>> vt_sp = osr.SpatialReference() >>> vt_sp.ImportFromEPSG(5646) 0 >>> vt_sp.GetName() 'NAD83 / Vermont (ftUS)'
- GetNormProjParm(self, name, default_val=0.0) double
Fetch a normalized projection parameter value.
This method is the same as
GetProjParm()except that the value of the parameter is normalized into degrees or meters depending on whether it is linear or angular.See
OGRSpatialReference::GetNormProjParm().- Parameters:
name (str) -- parameter name, available as constants prefixed with SRS_PP.
default_val (float, default = 0.0) -- value to return if this parameter doesn't exist
- Return type:
float
Examples
>>> vt_sp = osr.SpatialReference() >>> vt_sp.ImportFromEPSG(5646) 0 >>> vt_sp.GetProjParm(osr.SRS_PP_FALSE_EASTING) 1640416.6667 >>> vt_sp.GetNormProjParm(osr.SRS_PP_FALSE_EASTING) 500000.0000101601
- GetProjParm(self, name, default_val=0.0) double
Fetch a projection parameter value.
See
OGRSpatialReference::GetProjParm().- Parameters:
name (str) -- parameter name, available as constants prefixed with SRS_PP.
default_val (float, default = 0.0) -- value to return if this parameter doesn't exist
- Return type:
float
Examples
>>> vt_sp = osr.SpatialReference() >>> vt_sp.ImportFromEPSG(5646) 0 >>> vt_sp.GetProjParm(osr.SRS_PP_FALSE_EASTING) 1640416.6667 >>> vt_sp.GetProjParm(osr.SRS_PP_FALSE_NORTHING) 0.0
- GetSemiMajor(self) double
Get spheroid semi major axis (in meters starting with GDAL 3.0)
See
OGRSpatialReference::GetSemiMajor().- Returns:
semi-major axis, or
SRS_WGS84_SEMIMAJORif it cannot be found.- Return type:
float
- GetSemiMinor(self) double
Get spheroid semi minor axis.
See
OGRSpatialReference::GetSemiMinor().- Returns:
semi-minor axis, or
SRS_WGS84_SEMIMINORif it cannot be found.- Return type:
float
- GetTOWGS84(self) OGRErr
Fetch TOWGS84 parameter, if available.
See
OGRSpatialReference::GetTOWGS84().- Return type:
tuple
- GetTargetLinearUnits(self, target_key) double
Fetch linear units for a target.
See
OGRSpatialReference::GetTargetLinearUnits().- Parameters:
target_key (str) -- key to look un, such as 'PROJCS' or 'VERT_CS'
- Return type:
double
- GetUTMZone(self) int
Get UTM zone.
See
OGRSpatialReference::GetUTMZone().- Returns:
UTM zone number. Negative in the southern hemisphere and positive in the northern hemisphere. If the SRS is not UTM, zero will be returned.
- Return type:
int
- HasPointMotionOperation(self) bool
Check if a CRS has an associated point motion operation.
See
OGRSpatialReference::HasPointMotionOperation().- Return type:
bool
- HasTOWGS84(self) bool
Return whether the SRS has a TOWGS84 parameter.
See
OGRSpatialReference::GetTOWGS84().- Return type:
bool
- ImportFromCF1(keyValues, units='')
Import a CRS from netCDF CF-1 definitions.
http://cfconventions.org/cf-conventions/cf-conventions.html#appendix-grid-mappings
- ImportFromEPSG(self, arg) OGRErr
Initialize SRS based on EPSG geographic, projected or vertical CRS code.
Since GDAL 3.0, this method is identical to
ImportFromEPSGA().See
OGRSpatialReference::importFromEPSG().- Parameters:
arg (int) -- EPSG code to search in PROJ database
- Returns:
OGRERR_NONEon success, or an error code on failure- Return type:
int
Examples
>>> srs = osr.SpatialReference() >>> srs.ImportFromEPSG(4326) 0
- ImportFromEPSGA(self, arg) OGRErr
Initialize SRS based on EPSG geographic, projected or vertical CRS code.
Since GDAL 3.0, this method is identical to
ImportFromEPSG().See
OGRSpatialReference::importFromEPSGA().- Parameters:
arg (int) -- EPSG code to search in PROJ database
- Returns:
OGRERR_NONEon success, or an error code on failure- Return type:
int
- ImportFromERM(self, proj, datum, units) OGRErr
- ImportFromESRI(self, ppszInput) OGRErr
- ImportFromMICoordSys(self, pszCoordSys) OGRErr
- ImportFromOzi(self, papszLines) OGRErr
- ImportFromPCI(self, proj, units='METRE', argin=0) OGRErr
- ImportFromProj4(self, ppszInput) OGRErr
Initialize SRS based on PROJ coordinate string.
See
OGRSpatialReference::importFromProj4().- Parameters:
ppszInput (str) -- PROJ coordinate string
- Returns:
OGRERR_NONEon success, orOGRERR_CORRUPT_DATAon failure- Return type:
int
Examples
>>> srs = osr.SpatialReference() >>> srs.ImportFromProj4('+proj=utm +zone=18 +datum=WGS84') 0
- ImportFromUSGS(self, proj_code, zone=0, argin=0, datum_code=0) OGRErr
- ImportFromUrl(self, url) OGRErr
Initialize SRS based on a URL.
This method will download the spatial reference at a given URL and feed it into
SetFromUserInput()for you.See
OGRSpatialReference::importFromUrl().- Parameters:
url (str)
- Returns:
OGRERR_NONEon success, or an error code on failure- Return type:
int
- ImportFromWkt(self, ppszInput) OGRErr
Import from WKT string.
See
OGRSpatialReference::importFromWkt().- Parameters:
ppszInput (str) -- WKT string
- Returns:
OGRERR_NONEif import succeeds, orOGRERR_CORRUPT_DATAif it fails for any reason.- Return type:
int
- ImportFromXML(self, xmlString) OGRErr
- IsCompound(self) int
Check if this CRS is a compound CRS.
See
OGRSpatialReference::IsCompound().- Returns:
1 if the CRS is compound, 0 otherwise
- Return type:
int
- IsDerivedGeographic(self) int
Check if this CRS is a derived geographic CRS, such as a rotated long/lat grid.
See
OGRSpatialReference::IsDerivedGeographic().- Returns:
1 if the CRS is derived geographic, 0 otherwise
- Return type:
int
- IsDerivedProjected(self) int
- IsDynamic(self) bool
Check if this CRS is a dynamic coordinate CRS.
See
OGRSpatialReference::IsDynamic().- Return type:
bool
- IsGeocentric(self) int
Check if this SRS is a geocentric coordinate system.
See
OGRSpatialReference::IsGeocentric().- Returns:
1 if the SRS is geocentric, 0 otherwise
- Return type:
int
- IsGeographic(self) int
Check if this SRS is a geographic coordinate system.
See
OGRSpatialReference::IsGeographic().- Returns:
1 if the SRS is geographic, 0 otherwise
- Return type:
int
- IsLocal(self) int
Check if this CRS is a local CRS.
See
OGRSpatialReference::IsLocal().- Returns:
1 if the SRS is local, 0 otherwise
- Return type:
int
- IsProjected(self) int
Check if this SRS is a projected coordinate system.
See
OGRSpatialReference::IsProjected().- Returns:
1 if the SRS is projected, 0 otherwise
- Return type:
int
- IsSame(self, rhs, options=None) int
Determine if two spatial references describe the same system.
See
OGRSpatialReference::IsSame().- Parameters:
rhs (SpatialReference)
options (list or dict)
- Returns:
1 if the spatial references describe the same system, 0 otherwise
- Return type:
int
- IsSameGeogCS(self, rhs) int
Determine if two spatial references share the same geographic coordinate system.
See
OGRSpatialReference::IsSameGeogCS().- Parameters:
rhs (SpatialReference)
options (list or dict)
- Returns:
1 if the spatial references have the same GeogCS, 0 otherwise
- Return type:
int
- IsSameVertCS(self, rhs) int
Determine if two spatial references share the same vertical coordinate system.
See
OGRSpatialReference::IsSameVertCS().- Parameters:
rhs (SpatialReference)
options (list or dict)
- Returns:
1 if the spatial references have the same VertCS, 0 otherwise
- Return type:
int
- IsVertical(self) int
Check if this is a vertical coordinate system.
See
OGRSpatialReference::IsVertical().- Returns:
1 if the CRS is vertical, 0 otherwise
- Return type:
int
- MorphFromESRI(self) OGRErr
- MorphToESRI(self) OGRErr
- PromoteTo3D(self, name=None) OGRErr
- SetACEA(self, stdp1, stdp2, clat, clong, fe, fn) OGRErr
- SetAE(self, clat, clong, fe, fn) OGRErr
- SetAngularUnits(self, name, to_radians) OGRErr
- SetAttrValue(self, name, value) OGRErr
- SetAuthority(self, pszTargetKey, pszAuthority, nCode) OGRErr
- SetAxisMappingStrategy(self, strategy)
- SetBonne(self, stdp, cm, fe, fn) OGRErr
- SetCEA(self, stdp1, cm, fe, fn) OGRErr
- SetCS(self, clat, clong, fe, fn) OGRErr
- SetCompoundCS(self, name, horizcs, vertcs) OGRErr
- SetCoordinateEpoch(self, coordinateEpoch)
- SetDataAxisToSRSAxisMapping(self, nList) OGRErr
- SetEC(self, stdp1, stdp2, clat, clong, fe, fn) OGRErr
- SetEckertIV(self, cm, fe, fn) OGRErr
- SetEckertVI(self, cm, fe, fn) OGRErr
- SetEquirectangular(self, clat, clong, fe, fn) OGRErr
- SetEquirectangular2(self, clat, clong, pseudostdparallellat, fe, fn) OGRErr
- SetFromUserInput(self, name, options=None) OGRErr
- SetGEOS(self, cm, satelliteheight, fe, fn) OGRErr
- SetGH(self, cm, fe, fn) OGRErr
- SetGS(self, cm, fe, fn) OGRErr
- SetGaussSchreiberTMercator(self, clat, clong, sc, fe, fn) OGRErr
- SetGeocCS(self, name='unnamed') OGRErr
- SetGeogCS(self, pszGeogName, pszDatumName, pszEllipsoidName, dfSemiMajor, dfInvFlattening, pszPMName='Greenwich', dfPMOffset=0.0, pszUnits='degree', dfConvertToRadians=0.0174532925199433) OGRErr
- SetGnomonic(self, clat, clong, fe, fn) OGRErr
- SetHOM(self, clat, clong, azimuth, recttoskew, scale, fe, fn) OGRErr
- SetHOM2PNO(self, clat, dfLat1, dfLong1, dfLat2, dfLong2, scale, fe, fn) OGRErr
- SetIGH(self) OGRErr
- SetKrovak(self, clat, clong, azimuth, pseudostdparallellat, scale, fe, fn) OGRErr
- SetLAEA(self, clat, clong, fe, fn) OGRErr
- SetLCC(self, stdp1, stdp2, clat, clong, fe, fn) OGRErr
- SetLCC1SP(self, clat, clong, scale, fe, fn) OGRErr
- SetLCCB(self, stdp1, stdp2, clat, clong, fe, fn) OGRErr
- SetLinearUnits(self, name, to_meters) OGRErr
- SetLinearUnitsAndUpdateParameters(self, name, to_meters) OGRErr
- SetLocalCS(self, pszName) OGRErr
- SetMC(self, clat, clong, fe, fn) OGRErr
- SetMercator(self, clat, clong, scale, fe, fn) OGRErr
- SetMercator2SP(self, stdp1, clat, clong, fe, fn) OGRErr
- SetMollweide(self, cm, fe, fn) OGRErr
- SetNZMG(self, clat, clong, fe, fn) OGRErr
- SetNormProjParm(self, name, val) OGRErr
- SetOS(self, dfOriginLat, dfCMeridian, scale, fe, fn) OGRErr
- SetOrthographic(self, clat, clong, fe, fn) OGRErr
- SetPS(self, clat, clong, scale, fe, fn) OGRErr
- SetPolyconic(self, clat, clong, fe, fn) OGRErr
- SetProjCS(self, name='unnamed') OGRErr
- SetProjParm(self, name, val) OGRErr
- SetProjection(self, arg) OGRErr
- SetRobinson(self, clong, fe, fn) OGRErr
- SetSOC(self, latitudeoforigin, cm, fe, fn) OGRErr
- SetSinusoidal(self, clong, fe, fn) OGRErr
- SetStatePlane(self, zone, is_nad83=1, unitsname='', units=0.0) OGRErr
- SetStereographic(self, clat, clong, scale, fe, fn) OGRErr
- SetTM(self, clat, clong, scale, fe, fn) OGRErr
- SetTMG(self, clat, clong, fe, fn) OGRErr
- SetTMSO(self, clat, clong, scale, fe, fn) OGRErr
- SetTMVariant(self, pszVariantName, clat, clong, scale, fe, fn) OGRErr
- SetTOWGS84(self, p1, p2, p3, p4=0.0, p5=0.0, p6=0.0, p7=0.0) OGRErr
- SetTargetLinearUnits(self, target, name, to_meters) OGRErr
- SetUTM(self, zone, north=1) OGRErr
- SetVDG(self, clong, fe, fn) OGRErr
- SetVertCS(self, VertCSName='unnamed', VertDatumName='unnamed', VertDatumType=0) OGRErr
- SetVerticalPerspective(self, topoOriginLat, topoOriginLon, topoOriginHeight, viewPointHeight, fe, fn) OGRErr
- SetWellKnownGeogCS(self, name) OGRErr
- StripVertical(self) OGRErr
Convert a compound CRS into a horizontal CRS.
See
OGRSpatialReference::StripVertical().Added in version 3.6.
- Returns:
OGRERR_NONEon success, or an error code on failure- Return type:
int
- Validate(self) OGRErr
CoordinateTransformation
- class osgeo.osr.CoordinateTransformation(*args)
Python proxy of an
OGRCoordinateTransformation.- GetInverse(self) CoordinateTransformation
- TransformBounds(self, minx, miny, maxx, maxy, densify_pts)
Transform a boundary, densifying the edges to account for nonlinear transformations along these edges.
See
OCTTransformBounds().- Parameters:
minx (float) -- Minimum bounding coordinate of the first axis in source CRS
miny (float) -- Minimum bounding coordinate of the second axis in source CRS
maxx (float) -- Maximum bounding coordinate of the first axis in source CRS
maxy (float) -- Maximum bounding coordinate of the second axis in source CRS
densify_pts (int) -- The number of points to use to densify the bounding polygon. Recommended to use 21.
- Returns:
Transformed values of xmin, ymin, xmax, ymax
- Return type:
tuple
Examples
>>> wgs84 = osr.SpatialReference() >>> wgs84.ImportFromEPSG(4326) 0 >>> vt_sp = osr.SpatialReference() >>> vt_sp.ImportFromEPSG(5646) 0 >>> ct = osr.CoordinateTransformation(wgs84, vt_sp) >>> ct.TransformBounds(44.2,-72.5, 44.3, -72.4, 21) (1640416.67, 619626.43, 1666641.49, 656096.76) # rtol: 1e-6
- TransformPoint(CoordinateTransformation self, double [3] inout)
- TransformPoint(CoordinateTransformation self, double [4] inout) None
- TransformPoint(CoordinateTransformation self, double x, double y, double z=0.0) None
- TransformPoint(CoordinateTransformation self, double x, double y, double z, double t) None
Transform a single point.
See
OCTTransform().- Returns:
A tuple of (x, y, z) or (x, y, z, t) values, depending on the input.
- Return type:
tuple
Examples
>>> wgs84 = osr.SpatialReference() >>> wgs84.ImportFromEPSG(4326) 0 >>> vt_sp = osr.SpatialReference() >>> vt_sp.ImportFromEPSG(5646) 0 >>> ct = osr.CoordinateTransformation(wgs84, vt_sp) >>> # Transform a point from WGS84 lat/long to Vermont State Plane easting/northing >>> ct.TransformPoint(44.26, -72.58) (1619458.11, 641509.19, 0.0) # rtol: 1e-6 >>> ct.TransformPoint(44.26, -72.58, 103) (1619458.11, 641509.19, 103.0) # rtol: 1e-6
- TransformPointWithErrorCode(self, x, y, z, t)
Variant of
TransformPoint()that provides an error code.See
OCTTransformEx().- Parameters:
x (float)
y (float)
z (float)
t (float)
- Returns:
tuple of (x, y, z, t, error) values
- Return type:
tuple
- TransformPoints(self, nCount)
Transform multiple points.
See
OCTTransform().- Parameters:
arg -- A list of tuples, or a 2xN, 3xN, or 4xN numpy array
- Returns:
A list of tuples of (x, y, z) or (x, y, z, t) values, depending on the input.
- Return type:
list
Examples
>>> wgs84 = osr.SpatialReference() >>> wgs84.ImportFromEPSG(4326) 0 >>> vt_sp = osr.SpatialReference() >>> vt_sp.ImportFromEPSG(5646) 0 >>> ct = osr.CoordinateTransformation(wgs84, vt_sp) >>> # Transform two points from WGS84 lat/long to Vermont State Plane easting/northing >>> ct.TransformPoints([(44.26, -72.58), (44.26, -72.59)]) [(1619458.11, 641509.19, 0.0), (1616838.29, 641511.90, 0.0)] # rtol: 1e-6
>>> ct.TransformPoints(np.array([[44.26, -72.58], [44.26, -72.59]])) [(1619458.11, 641509.19, 0.0), (1616838.29, 641511.90, 0.0)] # rtol: 1e-6
- class osgeo.osr.CoordinateTransformationOptions(*args)
Proxy of C++ OGRCoordinateTransformationOptions class.
- SetAreaOfInterest(self, westLongitudeDeg, southLatitudeDeg, eastLongitudeDeg, northLatitudeDeg) bool
- SetBallparkAllowed(self, allowBallpark) bool
- SetDesiredAccuracy(self, accuracy) bool
- SetOnlyBest(self, onlyBest) bool
- SetOperation(self, operation, inverseCT=False) bool
- osgeo.osr.CreateCoordinateTransformation(src, dst, options=None) CoordinateTransformation
Create a
CoordinateTransformationusing a set ofCoordinateTransformationOptions.See
OCTNewCoordinateTransformationEx().- Parameters:
src (SpatialReference) -- source spatial reference system
dst (SpatialReference) -- target spatial reference system
options (CoordinateTransformationOptions)
- Return type: