0

I'm trying to use Douglas Peucker's algorithm in R. By executing the following code, I get the following error:

Px <- (1:100)/10
Py <- dnorm(Px,3,1)+dnorm(Px,7,1)+Px/10

### Example 1
### Simplification using epsilon

par(mfrow=c(2,2))
plot(Px,Py,type="l")
plot(DouglasPeuckerEpsilon(Px,Py,0.01),type="b",col=4)
Could not find the "DouglasPeuckerEpsilon" in R language.

This is because I do not have the DP package installed?

  • 2
    `DouglasPeuckerEpsilon` appears to come at least from `kmlShape` package. Install that and see if it works for you. – Roman Luštrik Feb 22 '17 at 17:34
  • When I need a function but don't know the package (and it isn't installed on my local R), I'll often google `cran `. Searching for `R ` is just too difficult, but `cran` often provides great hints. In this case (`cran DouglasPeuckerEpsilon`), `kmlShape` as Roman identified is near the top of the list. – r2evans Feb 22 '17 at 17:42
  • 1
    I installed the package `kmlShape` `install.packages("kmlShape")`, and I proceed to execute the statement: `plot(DouglasPeuckerEpsilon(Px, Py, 0.04), type = "b", col = 3)`. And I still get the error: `Error in plot(DouglasPeuckerEpsilon (Px, Py, 0.04), type = "b", col = 3); Could not find the "DouglasPeuckerEpsilon"` – Lizandro Luzon M Feb 22 '17 at 18:29

1 Answers1

1

Perform the following Steps:

  1. Install the package (kmlShape)
  2. Then load the Library (kmlShape)

    install.packages("kmlShape")
    
    library("kmlShape")
    

Then run plot(DouglasPeuckerEpsilon(Px,Py,0.01),type="b",col=4) for Ramer-Douglas-Peucker algorithm (RDP)

Frank
  • 66,179
  • 8
  • 96
  • 180
Mithunram
  • 48
  • 5
  • @LizandroLuzonM - I'm glad this helped you, Sometimes we tend to skip package load step after installing the package and we wonder what's wrong with the code or package :) !... – Mithunram Feb 22 '17 at 22:17