# shapely.simplify#

simplify(geometry, tolerance, preserve_topology=True, **kwargs)#

Returns a simplified version of an input geometry using the Douglas-Peucker algorithm.

Parameters:
geometryGeometry or array_like
tolerancefloat or array_like

The maximum allowed geometry displacement. The higher this value, the smaller the number of vertices in the resulting geometry.

preserve_topologybool, default True

By default (True), the operation will avoid creating invalid geometries (checking for collapses, ring-intersections, etc), but this is computationally more expensive.

**kwargs

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

Examples

```>>> from shapely import LineString, Polygon
>>> line = LineString([(0, 0), (1, 10), (0, 20)])
>>> simplify(line, tolerance=0.9)
<LINESTRING (0 0, 1 10, 0 20)>
>>> simplify(line, tolerance=1)
<LINESTRING (0 0, 0 20)>
>>> polygon_with_hole = Polygon(
...     [(0, 0), (0, 10), (10, 10), (10, 0), (0, 0)],
...     holes=[[(2, 2), (2, 4), (4, 4), (4, 2), (2, 2)]]
... )
>>> simplify(polygon_with_hole, tolerance=4, preserve_topology=True)
<POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (2 2, 2 4, 4 4, 4 2...>
>>> simplify(polygon_with_hole, tolerance=4, preserve_topology=False)
<POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))>
```