Skip to main content

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

Release files for simplify-polyline 0.1.0

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

Source distribution (sdist)

Source distribution for simplify-polyline 0.1.0
File Size Uploaded
simplify_polyline-0.1.0.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for simplify-polyline 0.1.0
File Interpreter ABI Platform
simplify_polyline-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.5 kB

Release files / simplify_polyline-0.1.0.tar.gz

Download URL simplify_polyline-0.1.0.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fcc1a359acb66d97ae5ddfbc04f15fd02784a3b69ee01c6f0a9f80b7f85ec621
BLAKE2b-256 checksum
How to use checksums
7b0617e11f62ce2b02443f6c3cf2011c5ebf69a627ec0749e8a29cfbfbafaecb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release files / simplify_polyline-0.1.0-py3-none-any.whl

Download URL simplify_polyline-0.1.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
620dfbc82d9c7eb7a520d489c333c4b87472d17568746098dc7db2e025f15bf5
BLAKE2b-256 checksum
How to use checksums
4b1840d478a4a23861b021e32ad99c66742a2a27e6b2c5e1ec820422ba8613c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.2

2 release files

0.0.1

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