Welcome to centerline’s documentation!¶
Roads, rivers and similar linear structures are often represented by long and complex polygons. Since one of the most important attributes of a linear structure is its length, extracting that attribute from a polygon can prove to be more or less difficult.
This library tries to solve this problem by creating the the polygon’s centerline using the Voronoi diagram.

Features¶
A command-line script for creating centerlines from a vector source file and saving them into a destination vector file:
create_centerlines
$ create_centerlines input.shp output.geojson
The
Centerline
class that allows integration into your own workflow.
>>> from shapely.geometry import Polygon
>>> from centerline.geometry import Centerline
>>> polygon = Polygon([[0, 0], [0, 4], [4, 4], [4, 0]])
>>> attributes = {"id": 1, "name": "polygon", "valid": True}
>>> centerline = Centerline(polygon, **attributes)
>>> centerline.id == 1
True
>>> centerline.name
'polygon'
>>> centerline.geoms
<shapely.geometry.base.GeometrySequence object at 0x7f7d24116210>
Contents:
- Installation
- Usage
- API
- Frequently Asked Questions
- Contributing
- Changelog
- 1.0.1 (2023-01-23)
- 1.0.0 (2023-01-07)
- 0.6.4 (2022-09-17)
- 0.6.3 (2020-01-02)
- 0.6.2 (2020-01-02)
- 0.6.1 (2020-01-02)
- 0.6.0 (2019-06-25)
- 0.5.2 (2019-01-27)
- 0.5.1 (2019-01-27)
- 0.5.0 (2018-09-09)
- 0.4.2 (2018-08-22)
- 0.4.1 (2018-01-07)
- 0.4.0 (2018-01-07)
- 0.3.0 (2017-11-26)
- 0.2.1 (2017-06-18)
- 0.2.0 (2017-06-18)
- 0.1.0 (2016-01-15)