Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fitodic/centerline
Calculate the polygon's centerline
https://github.com/fitodic/centerline
border centerline cli gis linear-structures polygon python screenshot shapefile spatial-data voronoi
Last synced: 3 months ago
JSON representation
Calculate the polygon's centerline
- Host: GitHub
- URL: https://github.com/fitodic/centerline
- Owner: fitodic
- License: mit
- Created: 2014-11-28T14:38:01.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-05-18T05:06:42.000Z (6 months ago)
- Last Synced: 2024-05-21T00:49:23.170Z (6 months ago)
- Topics: border, centerline, cli, gis, linear-structures, polygon, python, screenshot, shapefile, spatial-data, voronoi
- Language: Python
- Homepage: https://centerline.readthedocs.io
- Size: 406 KB
- Stars: 245
- Watchers: 9
- Forks: 51
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
- Citation: CITATION.cff
Awesome Lists containing this project
README
Centerline
==========.. image:: https://github.com/fitodic/centerline/actions/workflows/ci.yml/badge.svg?event=push
:target: https://github.com/fitodic/centerline/actions
:alt: Build status.. image:: https://codecov.io/gh/fitodic/centerline/branch/master/graph/badge.svg?token=S2WQ9OTR9O
:target: https://codecov.io/gh/fitodic/centerline
:alt: Test coverage status.. image:: https://readthedocs.org/projects/centerline/badge/?version=latest
:target: http://centerline.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status.. image:: https://img.shields.io/pypi/v/centerline.svg
:target: https://pypi.python.org/pypi/centerline
:alt: Version.. image:: https://pepy.tech/badge/centerline
:target: https://pepy.tech/project/centerline
:alt: Downloads.. figure:: docs/images/example.png
:align: centerRoads, 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``
.. code:: bash
$ create_centerlines input.shp output.geojson
* The ``Centerline`` class that allows integration into your own workflow.
.. code:: python
>>> 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