Package 'visvalingam'

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

Help Index


Calculation of effective areas for all nodes according to Visvalingam's line simplification algorithm

Description

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.

Usage

vis_effective_areas(x, y)

Arguments

x

points

y

points

Details

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.

Value

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.

Examples

set.seed(1)
N <- 10
x <- runif(N)
y <- runif(N)
vis_effective_areas(x, y)

Line simplification using Visvalingam's algorithm

Description

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.

Usage

vis_indices(x, y, n)

Arguments

x

points

y

points

n

number of points to keep

Value

logical vector giving location of the n simplified indices

Examples

set.seed(1)
N <- 10
x <- runif(N)
y <- runif(N)
vis_indices(x, y, 4)

Line simplification using Visvalingam's algorithm

Description

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.

Usage

vis_simplify(x, y, n)

Arguments

x, y

points

n

number of points to keep

Value

list with elements x and y of the simplified line

Examples

set.seed(1)
N <- 10
x <- runif(N)
y <- runif(N)
vis_simplify(x, y, 4)

Naive R implememtation of Visvalingam's line simplification algorithm

Description

This R code is going to remain unoptimised as a readable demonstration of the core algorithm.

Usage

vis_simplify_r(x, y, n)

Arguments

x, y

points

n

number of points to keep

Examples

set.seed(1)
N <- 10
x <- runif(N)
y <- runif(N)
vis_simplify_r(x, y, 4)