Skip to main content

Implementation of the straight skeleton algorithm as described by Felkel and Obdržálek in their 1998 conference paper Straight skeleton implementation.

Project description

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

Project details


Download files

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

Source Distribution

shapely_polyskel-0.1.2.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shapely_polyskel-0.1.2-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file shapely_polyskel-0.1.2.tar.gz.

File metadata

  • Download URL: shapely_polyskel-0.1.2.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for shapely_polyskel-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a615f5d7caa16e25be0e0dd609ece9ddde025fd737570286d0f00a7f9470d3bd
MD5 d9eaa2371f127e9b59b0e15c0283b550
BLAKE2b-256 d3d4c88f0e2b1919ec1109a0ca2b06bbc6b5183cda46dfced90829c60b7f5331

See more details on using hashes here.

Provenance

The following attestation bundles were made for shapely_polyskel-0.1.2.tar.gz:

Publisher: python-publish.yml on vec2pt/shapely-polyskel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file shapely_polyskel-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for shapely_polyskel-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 827400d0d733a41ca7cea40141aa2563d4c709f53feb42d54ccfd436b5cab1bc
MD5 e6363bfc2edb4b42fad55e95df4c88ef
BLAKE2b-256 b50190d3f3f93990aed34e49fa5071a842f76a5dfc2fdcb026f44a5115c9d969

See more details on using hashes here.

Provenance

The following attestation bundles were made for shapely_polyskel-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on vec2pt/shapely-polyskel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page