to_wkt(geometry, rounding_precision=6, trim=True, output_dimension=3, old_3d=False, **kwargs)#

Converts to the Well-Known Text (WKT) representation of a Geometry.

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

The following limitations apply to WKT serialization:

  • for GEOS <= 3.8 a multipoint with an empty sub-geometry will raise an exception

  • for GEOS <= 3.8 empty geometries are always serialized to 2D

  • for GEOS >= 3.9 only simple empty geometries can be 3D, collections are still always 2D

geometryGeometry or array_like
rounding_precisionint, default 6

The rounding precision when writing the WKT string. Set to a value of -1 to indicate the full precision.

trimbool, default True

If True, trim unnecessary decimals (trailing zeros).

output_dimensionint, default 3

The output dimension for the WKT string. Supported values are 2 and 3. Specifying 3 means that up to 3 dimensions will be written but 2D geometries will still be represented as 2D in the WKT string.

old_3dbool, default False

Enable old style 3D/4D WKT generation. By default, new style 3D/4D WKT (ie. “POINT Z (10 20 30)”) is returned, but with old_3d=True the WKT will be formatted in the style “POINT (10 20 30)”.


For other keyword-only arguments, see the NumPy ufunc docs.


The defaults differ from the default of the GEOS library. To mimic this, use:

to_wkt(geometry, rounding_precision=-1, trim=False, output_dimension=2)


>>> from shapely import Point
>>> to_wkt(Point(0, 0))
'POINT (0 0)'
>>> to_wkt(Point(0, 0), rounding_precision=3, trim=False)
'POINT (0.000 0.000)'
>>> to_wkt(Point(0, 0), rounding_precision=-1, trim=False)
'POINT (0.0000000000000000 0.0000000000000000)'
>>> to_wkt(Point(1, 2, 3), trim=True)
'POINT Z (1 2 3)'
>>> to_wkt(Point(1, 2, 3), trim=True, output_dimension=2)
'POINT (1 2)'
>>> to_wkt(Point(1, 2, 3), trim=True, old_3d=True)
'POINT (1 2 3)'