Skip to main content

shapely-polyskel

PyPI - Status PyPI - Version PyPI - Python Version

A straight skeleton

[!NOTE] This package is a fork of an implementation written by Ármin Scipiades (Botffy). The original code can be found under the link.

This is a Python 3 implementation of the straight skeleton algorithm as described by Felkel and Obdržálek in their 1998 conference paper Straight skeleton implementation.

The algorithm itself is fairly dated, and shown to be incorrect for certain input polygons. This implementation is a bit crap, and does not really attempt to fix the algorithm. It works kinda okay for most real-life input (for example country contours or floor plans).

For a modern and excellent overview of the topic please refer to Stefan Huber's excellent Computing Straight Skeleton and Motorcycle Graphs: Theory and Practice.

Installation

shapely-polyskel is available on PyPI:

pip install shapely-polyskel

Usage

Basic example (skeletonize)

from shapely_polyskel import skeletonize

rectangle = [(40, 40), (40, 310), (520, 310), (520, 40)]
skeleton = skeletonize(polygon=rectangle)

Polygon with holes (skeletonize)

from shapely_polyskel import skeletonize

rectangle = [(40, 40), (40, 310), (520, 310), (520, 40)]
holes = [[(100, 100), (200, 100), (200, 150), (100, 150)]]
skeleton = skeletonize(polygon=rectangle, holes=holes)

Basic example (StraightSkeleton)

from shapely import Polygon
from shapely_polyskel import StraightSkeleton

# In the case of using 'StraightSkeleton', the direction of the polygon/hole
# points is not important.

polygon = Polygon(
    [(520, 40), (520, 310), (40, 310), (40, 40)],
    [[(100, 150), (200, 150), (200, 100), (100, 100)]],
)

straight_skeleton = StraightSkeleton(polygon=polygon)

# Returns the same list as 'skeletonize'
skeleton = straight_skeleton.straight_skeleton

source_points = straight_skeleton.source_points(points3d=False)
ridges = straight_skeleton.ridges()
sinks = straight_skeleton.sinks()

More examples can be found in the notebooks folder.

Forks & ports

Release files for shapely-polyskel 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shapely-polyskel 0.1.2
File Size Uploaded
shapely_polyskel-0.1.2.tar.gz 17.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shapely-polyskel 0.1.2
File Interpreter ABI Platform
shapely_polyskel-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 32.1 kB

Release files / shapely_polyskel-0.1.2.tar.gz

Download URL shapely_polyskel-0.1.2.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a615f5d7caa16e25be0e0dd609ece9ddde025fd737570286d0f00a7f9470d3bd
BLAKE2b-256 checksum
How to use checksums
d3d4c88f0e2b1919ec1109a0ca2b06bbc6b5183cda46dfced90829c60b7f5331
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 5, 2025.

Transparency log

Release files / shapely_polyskel-0.1.2-py3-none-any.whl

Download URL shapely_polyskel-0.1.2-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
827400d0d733a41ca7cea40141aa2563d4c709f53feb42d54ccfd436b5cab1bc
BLAKE2b-256 checksum
How to use checksums
b50190d3f3f93990aed34e49fa5071a842f76a5dfc2fdcb026f44a5115c9d969
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 5, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page