read_geometry

geodetic_engine.geodesy.geometry.read_geometry(value, *, format=None, srid_authority='EPSG', axis_order='xy', crs=None)[source]

Read a geometry, and the CRS it states, from any encoding in FORMATS.

Parameters:
  • value (object) – WKT or EWKT text; WKB or EWKB as bytes or hex text in either case; a GeoJSON geometry object or Esri JSON geometry, as a mapping or JSON text; a Shapely geometry; or an object with a __geo_interface__. None reads as None.

  • format (Literal['wkt', 'wkb', 'wkb_hex', 'ewkt', 'ewkb', 'ewkb_hex', 'geojson', 'esrijson'] | None, default: None) – The encoding value is in, or None to tell from value.

  • srid_authority (str, default: "EPSG") – The authority an SRID is a code of: "EPSG", or any other in the active proj.db, such as "ESRI".

  • axis_order (Literal['xy', 'crs'], default: "xy") – "xy" when the coordinates are longitude or easting first, "crs" when they are in the CRS’s declared order.

  • crs (object, default: None) – The CRS value is in, when it does not say. Needed for axis_order="crs" then.

Return type:

tuple[Geometry | None, CoordinateReferenceSystem | None]

Returns:

The geometry, xy, and the CRS it is in – the one it states (an SRID, an Esri spatialReference), else crs, else None.

Raises:

Example

>>> geometry, crs = read_geometry(
...     "0101000020E6100000C7726EBA353F24405B39F0746B7E4E40"
... )
>>> geometry.wkt, crs.authority_code
('POINT (10.123456789 60.987654321)', 'EPSG:4326')