Package 'RDP'

Title: The Ramer-Douglas-Peucker Algorithm
Description: Pretty fast implementation of the Ramer-Douglas-Peucker algorithm for reducing the number of points on a 2D curve. Urs Ramer (1972), "An iterative procedure for the polygonal approximation of plane curves" <doi:10.1016/S0146-664X(72)80017-0>. David H. Douglas and Thomas K. Peucker (1973), "Algorithms for the Reduction of the Number of Points Required to Represent a Digitized Line or its Caricature" <doi:10.3138/FM57-6770-U75U-7727>.
Authors: Robert Dahl Jacobsen [aut, cre]
Maintainer: Robert Dahl Jacobsen <[email protected]>
License: GPL-3
Version: 0.3.0
Built: 2024-10-08 05:02:25 UTC
Source: https://github.com/robertdj/rdp

Help Index


RDP package

Description

Implementation of the Ramer-Douglas-Peucker algorithm.

Author(s)

Maintainer: Robert Dahl Jacobsen [email protected]

References

Urs Ramer (1972), "An iterative procedure for the polygonal approximation of plane curves". Computer Graphics and Image Processing 1, 244–256. doi:10.1016/S0146-664X(72)80017-0.

David H. Douglas and Thomas K. Peucker (1973), "Algorithms for the Reduction of the Number of Points Required to Represent a Digitized Line or its Caricature". Cartographica 10, 112–122. doi:10.3138/FM57-6770-U75U-7727.

See Also

Useful links:


Simplify a curve using the Ramer-Douglas-Peucker algorithm.

Description

Implements the Ramer-Douglas-Peucker algorithm for reducing the number of points on a curve.

Usage

RamerDouglasPeucker(x, y, epsilon, keep_index = FALSE)

Arguments

x

⁠[numeric]⁠ The x values of the curve as a vector without NA values.

y

⁠[numeric]⁠ The y values of the curve as a vector without NA values.

epsilon

⁠[positive numeric(1)]⁠ The threshold for filtering outliers from the simplified curve.

keep_index

⁠[logical]⁠ If TRUE, returns a column called index with the index locations of points that are kept.

Details

If there are no more than two points it does not make sense to simplify. In this case the input is returned without further checks of x and y. In particular, the input is not checked for NA values.

Value

A data.frame with x and y values of the simplified curve.

Examples

RDP::RamerDouglasPeucker(x = c(0, 1, 3, 5), y = c(2, 1, 0, 1), epsilon = 0.5)
RDP::RamerDouglasPeucker(x = c(0, 1, 3, 5), y = c(2, 1, 0, 1), epsilon = 0.5, keep_index = TRUE)