Description Usage Arguments Details Value See Also Examples
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.
1 | compute_vw_distance(data, x_var, y_var)
|
data |
A data frame like object. |
x_var,y_var |
Formulas specifying either variable names or expressions to use as x and y positions. |
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.
A data frame with columns:
x_,y_ |
Position |
distance_ |
Distance between point and sub-line |
geometry_simplify()
for an function that works on a
geometry and does simplification given tolerance or percentage of points to
keep.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.