pyinterp.geometry.geographic.algorithms.from_wkt

Contents

pyinterp.geometry.geographic.algorithms.from_wkt#

pyinterp.geometry.geographic.algorithms.from_wkt(wkt: str) → pyinterp.core.geometry.geographic.Point | pyinterp.core.geometry.geographic.LineString | pyinterp.core.geometry.geographic.Ring | pyinterp.core.geometry.geographic.Polygon | pyinterp.core.geometry.geographic.MultiPoint | pyinterp.core.geometry.geographic.MultiLineString | pyinterp.core.geometry.geographic.MultiPolygon#

Creates a geometry from Well-Known Text (WKT) representation.

Parses a WKT string and constructs the corresponding geometry object. The function automatically detects the geometry type from the WKT string and returns the appropriate geometry object.

Parameters:

wkt – WKT string representation of the geometry.

Returns:

Point, LineString, Ring, Polygon, MultiPoint, MultiLineString, or MultiPolygon depending on the WKT content.

Return type:

A variant containing one of

Examples

>>> point = from_wkt("POINT(1 2)")
>>> # Returns Point(1.0, 2.0)
>>> polygon = from_wkt("POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))")
>>> # Returns Polygon object
>>> linestring = from_wkt("LINESTRING(0 0, 1 1, 2 2)")
>>> # Returns LineString object