Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Generate a raster to play with
- library(raster)
- library(RStoolbox)
- mat = matrix(c(1,2,4,4),nrow=2,ncol=2)
- ras=raster(mat)
- # Use ggplot2::fortify() to turn it into a data.frame
- ras.fort = ggplot2::fortify(ras)
- # Select the raster values you're interested in (here, for example, 4)
- mylocs = ras.fort[ras.fort$layer==4,]
- # `x` and `y` columns are your coordinates
- > r = raster(matrix(runif(50*50),50,50))
- > coords = coordinates(r)[r[]>0.9,]
- > plot(r)
- > points(coords)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement