Simplify an open or closed polyline
Project description
simplify_polyline
Simplify an open or closed polyline.
Two functions:
Visvalingham-Whyatt removes the smallest triangles formed by three consecutive points in a polyline or polygon. The big advantage for my purposes is that the starting point on a polygon will not affect the result. The big disadvantage is that tall, thin spikes are removed along with short, thin triangles. So the smoothed polygon or polyline may not fit in anything close to the convex hull of the input.
use the Visvalingham-Whyatt algorithm with vs_simplify
Douglas-Peucker gives a better representation of the convex hull. The big
disadvantage with Douglas-Peucker is that the starting point on a polygon will affect
the result. I've addressed this in the slow, but ideal (for my purposes) simplify
function.
use the Douglas-Peucker algoritm with simplify
This will usually be the better choice.
arguments
verts vertices along polyline. Anything that can be cast into a '*, 2' array.
(simplify
) min_dist minimum height above a line segment for a point to be
included.
(vw_simplify
) min_area minimum area of a triangle for a point to be
included.
is_closed optionally specify whether verts describe a polyline or polygon. If not specified, is_closed is inferred from verts[0] == verts[-1]. The form of the input (last vert == first vert) will be replicated in the output.
If verts is (a, b, c, d, a), return value will be (a, ..., a)
If verts is (a, b, c, d), and is_closed is True, return value will be (a, ..., d)
So, there are two ways to deal with closed polygons:
-
close by repeating first point at the end. Return value will keep this format
-
close by specifying
is_closed
. Return value will not repeat last point
install
pip install simplify_polyline
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file simplify_polyline-0.1.0.tar.gz
.
File metadata
- Download URL: simplify_polyline-0.1.0.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcc1a359acb66d97ae5ddfbc04f15fd02784a3b69ee01c6f0a9f80b7f85ec621 |
|
MD5 | 43a93e041fa4256bd0d50ec2c9015f4d |
|
BLAKE2b-256 | 7b0617e11f62ce2b02443f6c3cf2011c5ebf69a627ec0749e8a29cfbfbafaecb |
File details
Details for the file simplify_polyline-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: simplify_polyline-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 620dfbc82d9c7eb7a520d489c333c4b87472d17568746098dc7db2e025f15bf5 |
|
MD5 | 53f3aa695ee2bb7d2d783a3ff4183f22 |
|
BLAKE2b-256 | 4b1840d478a4a23861b021e32ad99c66742a2a27e6b2c5e1ec820422ba8613c6 |