Title: | Visvalingam-Wyatt Polyline Simplification |
---|---|
Description: | Visvalingam-Wyatt polyline simplification. |
Authors: | mikefc |
Maintainer: | mikefc <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.2 |
Built: | 2024-11-15 04:21:09 UTC |
Source: | https://github.com/coolbutuseless/visvalingam |
In visvalingam's algorithm, each vertex in the line has an associated effective area. This value is the area of the triangle defined by the current vertex and its two neighbours at the time when the simplification process deletes it as a node.
vis_effective_areas(x, y)
vis_effective_areas(x, y)
x |
points |
y |
points |
This function calculates the effective area for all points (with area = Inf
for the frist and last point). This value could then be used to set a
threshold level and select subsets of points.
numeric vector of areas - one for each point. The first and last points are assigned an infinite area. Runs of duplicate points will have an effective area of zero.
set.seed(1) N <- 10 x <- runif(N) y <- runif(N) vis_effective_areas(x, y)
set.seed(1) N <- 10 x <- runif(N) y <- runif(N) vis_effective_areas(x, y)
Visvalingam's algorithm iteratively deletes vertices from a line based up
the effecive area
of the triangle defined by the vertex and its
current neighbours.
vis_indices(x, y, n)
vis_indices(x, y, n)
x |
points |
y |
points |
n |
number of points to keep |
logical vector giving location of the n
simplified indices
set.seed(1) N <- 10 x <- runif(N) y <- runif(N) vis_indices(x, y, 4)
set.seed(1) N <- 10 x <- runif(N) y <- runif(N) vis_indices(x, y, 4)
Visvalingam's algorithm iteratively deletes vertices from a line based up
the effecive area
of the triangle defined by the vertex and its
current neighbours.
vis_simplify(x, y, n)
vis_simplify(x, y, n)
x , y
|
points |
n |
number of points to keep |
list with elements x
and y
of the simplified line
set.seed(1) N <- 10 x <- runif(N) y <- runif(N) vis_simplify(x, y, 4)
set.seed(1) N <- 10 x <- runif(N) y <- runif(N) vis_simplify(x, y, 4)
This R code is going to remain unoptimised as a readable demonstration of the core algorithm.
vis_simplify_r(x, y, n)
vis_simplify_r(x, y, n)
x , y
|
points |
n |
number of points to keep |
set.seed(1) N <- 10 x <- runif(N) y <- runif(N) vis_simplify_r(x, y, 4)
set.seed(1) N <- 10 x <- runif(N) y <- runif(N) vis_simplify_r(x, y, 4)