gws.gis.crs

Source code: gws.gis.crs

Package Contents

gws.gis.crs.best_axis(crs: gws.Crs, protocol: gws.OwsProtocol = None, protocol_version: str = None, crs_format: gws.CrsFormat = None, inverted_crs: list[gws.Crs] | None = None) gws.Axis

Return the ‘best guess’ axis under given circumstances.

Parameters:
  • crs – target CRS

  • protocol – OWS protocol (WMS, WFS…)

  • protocol_version – protocol version

  • crs_format – the format the target_crs was obtained from

  • inverted_crs – user-provided list of CRSes known to have an inverted (YX) axis

Returns:

An axis

gws.gis.crs.best_bounds(crs: gws.Crs, supported_bounds: list[gws.Bounds]) gws.Bounds

Return the best one from the list of supported bounds.

Parameters:
  • crs – target CRS

  • supported_bounds – Bounds list

Returns:

A Bounds object

gws.gis.crs.best_match(crs: gws.Crs, supported_crs: list[gws.Crs]) gws.Crs

Return a crs from the list that most closely matches the given crs.

Parameters:
  • crs – target CRS

  • supported_crs – CRS list

Returns:

A CRS object

exception gws.gis.crs.Error

Bases: gws.Error

GWS error.

gws.gis.crs.get(crs_name: gws.CrsName) gws.Crs | None

Returns the CRS for a given CRS-code or SRID.

class gws.gis.crs.Object(**kwargs)

Bases: gws.Crs

Coordinate reference system.

axis_for_format(fmt)

Get the axis depending on the string format.

We adhere to the GeoServer convention here: https://docs.geoserver.org/latest/en/user/services/wfs/axis_order.html

to_geojson()

Return a geojson representation of the CRS (as per GJ2008).

Returns:

A GeoJson dict.

References

https://geojson.org/geojson-spec#named-crs

to_string(fmt=None)

Return a string representation of the CRS.

Parameters:

fmt – Format to use.

Returns:

A string.

transform_extent(ext, crs_to)

Transform an Extent from this CRS to another.

Parameters:
  • extent – Extent.

  • crs_to – Target CRS.

Returns:

A transformed Extent.

transformer(crs_to)

Create a transformer function to another CRS.

Parameters:

crs_to – Target CRS.

Returns:

A function.

gws.gis.crs.parse(crs_name: gws.CrsName) tuple[gws.CrsFormat, gws.Crs | None]

Parses a CRS to a tuple of CRS-format and the CRS itself.

gws.gis.crs.require(crs_name: gws.CrsName) gws.Crs

Raises an error if no correct CRS is given.

gws.gis.crs.WEBMERCATOR
gws.gis.crs.WEBMERCATOR_BOUNDS
gws.gis.crs.WEBMERCATOR_RADIUS = 6378137
gws.gis.crs.WEBMERCATOR_SQUARE = ()
gws.gis.crs.WGS84
gws.gis.crs.WGS84_BOUNDS