Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. # Generate a raster to play with
  2. library(raster)
  3. library(RStoolbox)
  4. mat = matrix(c(1,2,4,4),nrow=2,ncol=2)
  5. ras=raster(mat)
  6.  
  7. # Use ggplot2::fortify() to turn it into a data.frame
  8. ras.fort = ggplot2::fortify(ras)
  9.  
  10. # Select the raster values you're interested in (here, for example, 4)
  11. mylocs = ras.fort[ras.fort$layer==4,]
  12. # `x` and `y` columns are your coordinates
  13.  
  14. > r = raster(matrix(runif(50*50),50,50))
  15. > coords = coordinates(r)[r[]>0.9,]
  16.  
  17. > plot(r)
  18. > points(coords)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement