Skip to main content

Calculate the centerline of a polygon

Project description

Build Documentation Status Coverage Version Downloads

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. For more info on how to use this package, see the official documentation.


  • 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)
>>> == 1
>>> centerline.geoms
<shapely.geometry.base.GeometrySequence object at 0x7f7d24116210>

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for centerline, version 0.6.3
Filename, size File type Python version Upload date Hashes
Filename, size centerline-0.6.3-py2.py3-none-any.whl (7.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size centerline-0.6.3.tar.gz (148.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page