How to extract the values from a raster in R

Viewed 10244

I want to use R to extract values from a raster. Basically, my raster has values from 0-6 and I want to extract for every single pixel the corresponding value. So that I have at the end a data table containing those two variables.

Thank you for your help, I hope my explanations are precisely enough.

3 Answers

How about simply doing

as.data.frame(s, xy=TRUE) # s is your raster file 
Related