compute_dp_distance: Compute the Douglas-Peucker distance for paths.

Description Usage Arguments Details Value See Also Examples

Description

Douglas-Peucker is a recursive line simplification algorithm. It starts by defining a line from the first to the last point, and then finds the point that is furthest from the line. It then recursively breaks up the into two pieces around the furthest point, and finds the furthest point from those sublines. See http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm for more details.

Usage

1
compute_dp_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

Note that this function does not do any simplification - it just adds an additional column the measures the distaince between each point and it subline. 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
4
5
6
x <- 1:10
y <- x * 2
df <- data.frame(x, y)

# For a straight line, can remove all points except first and last
compute_dp_distance(df, ~x, ~y)

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