cartagen.remove_flat_vertices

cartagen.remove_flat_vertices#

remove_flat_vertices(geom, tolerance=5.0)#

Removes flat vertices from a geometry.

A vertex is considered flat when the interior angle it forms with its two neighbours is close to 180°, meaning the three points are nearly collinear and the vertex brings no geometric information. Removing such vertices simplifies the geometry without altering its shape.

Parameters:
Returns:

LineString, MultiLineString, Polygon, MultiPolygon, or LinearRing – A simplified geometry of the same type as the input.

Examples

>>> polygon = Polygon([(0, 0), (0.5, 0), (1, 0), (1, 1), (0, 1)])
>>> remove_flat_vertices(polygon)
<POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))>

(Source code)

../_images/remove_flat_vertices.png