Skip to Content

car_ellipses.rsx

  1. ##Ellipse=group
  2. ##Layer=vector
  3. ##Field=Field Layer
  4. ##stdv= number 0.5
  5. ##Car_shape = output vector
  6. ##weighted=boolean True.
  7. # stdv : choix de la valeur normale ou intervalle de confiance (de 0 à 1)
  8. # weighted pondéré par le champs Field ou non pondéré
  9. library(car)
  10. coords<-coordinates(Layer)
  11. weights=Layer[[Field]]
  12. if(weighted) {
  13. sa = dataEllipse(coords, levels=c(stdv), weights=weights,segments = 100, draw = FALSE)
  14. }else {
  15. sa = dataEllipse(coords, levels=c(stdv),segments = 100, draw = FALSE)
  16. }
  17. sp = SpatialPolygons( list( Polygons(list(Polygon(sa)), 1)))
  18. sp.df <- data.frame( ID=1:length(sp))
  19. res = SpatialPolygonsDataFrame(sp,sp.df)
  20. proj4string(res) <- Layer@proj4string
  21. Car_shape<-res