shapely-polyskel 0.1.1

Creator: bigcodingguy24

Last updated:

Add to Cart

Description:

shapelypolyskel 0.1.1

shapely-polyskel




[!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

Yongha Hwang's fork. Check out it to see polyskel in sweet real-life action :heart: :heart: :heart:.
Polyskel-Swift a Swift port.
bpolyskel is a port for Blender, making some sweet roofs :heart:.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.