Skip to Content

dataframe spatial

  1. > library(sp)
  2.  
  3. > # transformation du dataframe originel en un dataframe spatial
  4. > coordinates(mes_données) <- ~ x+y
  5.  
  6. > # résultat
  7. > class(mes_données)
  8. [1] "SpatialPointsDataFrame"
  9. attr(,"package")
  10. [1] "sp"
  11.  
  12. > str(mes_données)
  13. Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
  14. ..@ data :'data.frame': 7 obs. of 2 variables:
  15. .. ..$ id : int [1:7] 1 2 3 4 5 6 7
  16. .. ..$ test: Factor w/ 7 levels "a ","b ","c ",..: 1 2 3 4 5 6 7
  17. ..@ coords.nrs : int [1:2] 2 3
  18. ..@ coords : num [1:7, 1:2] 235 245 255 265 275 285 295 424 444 464 ...
  19. .. ..- attr(*, "dimnames")=List of 2
  20. .. .. ..$ : NULL
  21. .. .. ..$ : chr [1:2] "x" "y"
  22. ..@ bbox : num [1:2, 1:2] 235 424 295 544
  23. .. ..- attr(*, "dimnames")=List of 2
  24. .. .. ..$ : chr [1:2] "x" "y"
  25. .. .. ..$ : chr [1:2] "min" "max"
  26. ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
  27. .. .. ..@ projargs: chr NA