centerline

fitodicMIT活跃维护

用 Python 计算多边形中心线的工具,基于 Voronoi 图把面状地物(如河流、道路)提取成线状结构,支持 shapefile 等空间数据,也可命令行调用。

Calculate the polygon's centerline

1.0.1发布于 2024-01-03 19:36 UTC297star58fork同步于 2026-11-11 00:00 UTC

怎么上手

由 README 提炼,执行前请确认
pip install centerline
硬件要求按 README 说明

README 未说明

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 Voronoi 图从道路河流等长条多边形中提取中心线,方便计算长度

用 Python 计算多边形中心线的工具,基于 Voronoi 图把面状地物(如河流、道路)提取成线状结构,支持 shapefile 等空间数据,也可命令行调用。

核心能力

  • 基于 Voronoi 图生成多边形中心线
  • 提供 create_centerlines 命令行脚本转换矢量文件
  • 提供 Centerline 类可嵌入自有工作流
  • 支持附加自定义属性并随几何对象保留

容易踩的坑

README 未说明是否需要额外安装 GEOS 等系统依赖;命令行需输入矢量文件格式,输出格式由扩展名决定

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本1.0.1
  1. 1.0.1最新正式版2024-01-03 · 2024-01-03 19:36 UTC

    这个版本没有写更新说明。

  2. 0.52018-09-09 · 2018-09-09 15:38 UTC
    查看更新说明

    Added

    • MultiPolygon support
  3. 0.4.22018-09-09 · 2018-09-09 15:28 UTC
    查看更新说明

    Added

    • GDAL 2.3.1 to the CI configuration

    Changed

    • Moved the coverage configuration to setup.cfg
    • Moved the package's metadata to setup.cfg

    Fixed

    • Error when MultiLineString degenerates into LineString (#14). Thanks mxwell!

    Removed

    • MANIFEST.in
    • Centerline from the centerline namespace. To import the Centerline class, use from centerline.main import Centerline
  4. 0.4.12018-01-07 · 2018-01-07 17:46 UTC
    查看更新说明

    Fixed

    • Ignore the osgeo package when building the documentation on readthedocs.org
  5. 0.42018-01-07 · 2018-01-07 17:45 UTC
    查看更新说明

    Added

    • Sphinx documentation

    Fixed

    • Add a comma to the list of development requirements

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    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: center

    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 <https://en.wikipedia.org/wiki/Voronoi_diagram>. For more info on how to use this package, see the official documentation <http://centerline.readthedocs.io/>.

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