Skip to content

fitodic/centerline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

36451c6 · Sep 14, 2024
Sep 14, 2024
May 26, 2024
Jan 7, 2023
May 26, 2024
Jan 7, 2023
May 26, 2024
Jan 7, 2023
Jan 7, 2023
May 26, 2024
Jan 3, 2024
Jun 25, 2019
Aug 22, 2018
Jan 3, 2024
Jan 7, 2023
Sep 14, 2024
Sep 14, 2024
Jun 25, 2019
Sep 14, 2024

Repository files navigation

Centerline

Build status Test coverage status Documentation Status Version Downloads
docs/images/example.png

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.

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.geometry.geoms
<shapely.geometry.base.GeometrySequence object at 0x7f7d24116210>