RSGISLib Projection Tools

Representation

rsgislib.tools.projection.get_epsg_code_from_wkt(wkt_str: str) int

Using GDAL to return the EPSG code for inputted WKT string.

Returns

the EPSG code.

rsgislib.tools.projection.get_wkt_from_epsg_code(epsg_code: int) str

Using GDAL to return the WKT string for inputted EPSG Code.

Parameters

epsg_code – integer variable of the epsg code.

Returns

string with WKT representation of the projection.

GDAL / OSR

rsgislib.tools.projection.get_osr_prj_obj(epsg_code: int) <osgeo.osr.SpatialReference; proxy of <Swig Object of type 'OSRSpatialReferenceShadow *' at 0x7f1cc4271c90> >

A function which returns an OSR SpatialReference object for a given EPSG code.

Parameters

epsg_code – An EPSG code for the projection. Must be an integer.

Returns

osr.SpatialReference object.

Conversion

rsgislib.tools.projection.degrees_to_metres(latitude: float, lon_size: float, lat_size: float) -> (<class 'float'>, <class 'float'>)

Convert pixel sizes or distances in degrees to metres.

Parameters
  • latitude – latitude

  • lon_size – numpy array of x pixel sizes (degrees)

  • lat_size – numpy array of y pixel sizes (degrees)

Returns

x_size (numpy array of x pixel sizes (m)), y_size (numpy array of y pixel sizes (m))

from rsgislib import tools
x_size, y_size = tools.degrees_to_metres(52,1.0,1.0)
rsgislib.tools.projection.metres_to_degrees(latitude: float, x_size: float, y_size: float) -> (<class 'float'>, <class 'float'>)

Convert pixel sizes or distances in metres to degrees.

Parameters
  • latitude – latitude

  • x_size – numpy array of x pixel sizes (m)

  • y_size – numpy array of y pixel sizes (m)

Returns

lon_size (numpy array of x pixel sizes (degrees)), lat_size (numpy array of y pixel sizes (degrees))

from rsgislib import tools
x_size, y_size = tools.metres_to_degrees(52, 1.0, 1.0)

Numeric Representation

rsgislib.tools.projection.get_deg_coord_as_str(lat: float, lon: float, n_chars: int = 4) str
Parameters
  • lat

  • lon

  • n_chars

Returns