compute_vw_distance: Compute the distance for paths with the Visvalingam-Whyatt...

Description Usage Arguments Details Value See Also Examples

Description

Visvalingam-Whyatt is a method of simplifying lines. It starts by computing the area of the triangle formed by each sequence of three points. (The triangles are overlapping.) Then it removes the middle point of the triangle with the smallest area, and recomputes the area of the neighbor triangles that are affected by the removal of that point. This repeats until all the points are removed except the two endpoints.

Usage

1
compute_vw_distance(data, x_var, y_var)

Arguments

data

A data frame like object.

x_var,y_var

Formulas specifying either variable names or expressions to use as x and y positions.

Details

See http://bost.ocks.org/mike/simplify/ for more details.

Note that this function does not do any simplification - it just adds an additional column the measures the area of the triangle at each point (where the point is the middle point of the triangle). Filtering on this column will perform simplification.

Value

A data frame with columns:

x_,y_

Position

distance_

Distance between point and sub-line

See Also

geometry_simplify() for an function that works on a geometry and does simplification given tolerance or percentage of points to keep.

Examples

1
2
3
df <- data.frame(x = c(1,2,3,4,5), y = c(1,1.2,3.8,3.3,5))

# compute_vw_distance(df, ~x, ~y)

rstudio/gggeom documentation built on May 28, 2019, 4:35 a.m.