0

I try to smooth R with a set point as follows:

myshp <- shapefile("C:/Users/zina/workspace/Proj_Meteo/interpolate/DZA_adm/DZA_adm0.shp")

px<-c(2.7828,2.7828,2.6828,2.5828,2.4828,2.3828,2.3828,2.2828,2.1828,2.0828
      ,1.9828,1.8828,1.7828,1.6828,1.5828,1.4828,1.3828,1.2828,1.1828,1.0828
      ,0.9828,0.8828,0.7828,0.6828,0.5828,0.4828,0.3828,0.2828,0.1828,0.0828
      ,-0.0172,-0.0172,-0.1172,-0.2172,-0.3172,-0.4172,-0.5172,-0.6172,-0.7172,-0.7172
      ,-0.8172,-0.9172,-1.0172,-1.0172,-1.1172,-1.1172,-1.0172,-1.0172,-0.9172,-0.8172
      ,-0.8172,-0.7172,-0.6172,-0.5172,-0.4172,-0.3172,-0.3172,-0.2172,-0.2172,-0.3172
      ,-0.4172,-0.5172,-0.5172,-0.6172,-0.7172,-0.8172,-0.9172,-1.0172,-1.1172,-1.1172
      ,-1.0172,-0.9172,-0.8172,-0.7172,-0.6172,-0.5172,-0.5172,-0.4172,-0.3172,-0.2172
      ,-0.1172,-0.0172,0.0828,0.1828,0.2828,0.3828,0.3828,0.4828,0.5828,0.5828
      ,0.6828,0.7828,0.7828,0.8828,0.9828,1.0828,1.1828,1.2828,1.3828,1.4828
      ,1.5828,1.6828,1.6828,1.7828,1.8828,1.8828,1.9828,2.0828,2.0828,2.1828
      ,2.2828,2.3828,2.4828,2.5828,2.6828,2.7828,2.8828,2.9828,3.0828,3.1828
      ,3.2828,3.3828,3.4828,3.5828,3.6828,3.7828,3.8828,3.9828,4.0828,4.1828
      ,4.2828,4.3828,4.4828,4.5828,4.6828,4.7828,4.8828,4.9828,5.0828,5.1828
      ,5.2828,5.3828,5.4828,5.5828,5.6828,5.7828,5.8828,5.9828,5.9828,5.9828
      ,5.8828,5.7828,5.7828,5.7828,5.6828,5.5828,5.4828,5.3828,5.2828,5.1828
      ,5.0828,4.9828,4.9828,4.8828,4.7828,4.6828,4.6828,4.5828,4.4828,4.4828
      ,4.3828,4.2828,4.2828,4.1828,4.0828,3.9828,3.9828,3.8828,3.7828,3.6828
      ,3.5828,3.4828,3.3828,3.3828,3.2828,3.1828,3.0828,3.0828,2.9828,2.8828
      ,2.7828)
py<-c(32.3764 ,31.9764 ,31.9764 ,31.9764 ,31.9764 ,31.9764 ,31.5764 ,31.5764 ,31.5764 ,31.5764
      ,31.5764 ,31.5764 ,31.5764 ,31.5764 ,31.5764 ,31.5764 ,31.5764 ,31.5764 ,31.5764 ,31.5764
      ,31.5764 ,31.5764 ,31.5764 ,31.5764 ,31.5764 ,31.5764 ,31.5764 ,31.5764 ,31.5764 ,31.5764
      ,31.5764 ,31.9764 ,31.9764 ,31.9764 ,31.9764 ,31.9764 ,31.9764 ,31.9764 ,31.9764 ,32.3764
      ,32.3764 ,32.3764 ,32.3764 ,32.7764 ,32.7764 ,33.1764 ,33.1764 ,33.5764 ,33.5764 ,33.5764
      ,33.9764 ,33.9764 ,33.9764 ,33.9764 ,33.9764 ,33.9764 ,34.3764 ,34.3764 ,34.7764 ,34.7764
      ,34.7764 ,34.7764 ,35.1764 ,35.1764 ,35.1764 ,35.1764 ,35.1764 ,35.1764 ,35.1764 ,35.5764
      ,35.5764 ,35.5764 ,35.5764 ,35.5764 ,35.5764 ,35.5764 ,35.9764 ,35.9764 ,35.9764 ,35.9764
      ,35.9764 ,35.9764 ,35.9764 ,35.9764 ,35.9764 ,35.9764 ,36.3764 ,36.3764 ,36.3764 ,35.9764
      ,35.9764 ,35.9764 ,35.5764 ,35.5764 ,35.5764 ,35.5764 ,35.5764 ,35.5764 ,35.5764 ,35.5764
      ,35.5764 ,35.5764 ,35.9764 ,35.9764 ,35.9764 ,36.3764 ,36.3764 ,36.3764 ,36.7764 ,36.7764
      ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764
      ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764
      ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764
      ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.7764 ,36.3764 ,35.9764
      ,35.9764 ,35.9764 ,35.5764 ,35.1764 ,35.1764 ,35.1764 ,35.1764 ,35.1764 ,35.1764 ,35.1764
      ,35.1764 ,35.1764 ,34.7764 ,34.7764 ,34.7764 ,34.7764 ,34.3764 ,34.3764 ,34.3764 ,33.9764
      ,33.9764 ,33.9764 ,33.5764 ,33.5764 ,33.5764 ,33.5764 ,33.1764 ,33.1764 ,33.1764 ,33.1764
      ,33.1764 ,33.1764 ,33.1764 ,32.7764 ,32.7764 ,32.7764 ,32.7764 ,32.3764 ,32.3764 ,32.3764,32.3764)


      require(Hmisc) #for Bezier curve

      bz <- bezier(px,py)
      plot(myshp)
      poly<-polygon(bz$x,bz$y, col=rgb(0,0,1,0.5),border=NA)

Here's the resulat, smoothing is not currently adequatea rectangle that spell I don't understand its origin. result

Can someone tell me the problem because I can't manage to capture it.

1 Answer 1

1

Use a smaller evaluation, e.g.:

bz <- bezier(px, py, evaluation=50)

It's because the const <- (1 - z)^(n - 1) part of bezier evaluates to zero near the end of the evaluation points. It doesn't look like a particularly stable function, but I can't say that I know the Bézier curve algorithms. Consider notifying the maintainer of Hmisc of this behaviour.

1
  • ultimately it's a stupid thing that I stayed all day looking for !! big thank you @Mike T
    – zina_GIS
    Oct 19, 2014 at 23:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.