shapely.from_wkt

Contents

shapely.from_wkt#

from_wkt(geometry, on_invalid='raise', **kwargs)#

Create geometries from the Well-Known Text (WKT) representation.

The Well-known Text format is defined in the OGC Simple Features Specification for SQL.

Parameters:
geometrystr or array_like

The WKT string(s) to convert.

on_invalid{“raise”, “warn”, “ignore”, “fix”}, default “raise”

Indicates what to do when an invalid WKT string is encountered. Note that the validations involved are very basic, e.g. the minimum number of points for the geometry type. For a thorough check, use is_valid() after conversion to geometries. Valid options are:

  • raise: an exception will be raised if any input geometry is invalid.

  • warn: a warning will be raised and invalid WKT geometries will be returned as None.

  • ignore: invalid geometries will be returned as None without a warning.

  • fix: an effort is made to fix invalid input geometries (currently just unclosed rings). If this is not possible, they are returned as None without a warning. Requires GEOS >= 3.11.

**kwargs

See NumPy ufunc docs for other keyword arguments.

Examples

>>> from_wkt('POINT (0 0)')
<POINT (0 0)>