Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(raster)
- r <- raster()
- set.seed(0)
- values(r) <- runif(ncell(r), min = 0, max = 1000)
- coords = cbind(runif(25, min = -100, max = 100),
- runif(25, min = -50, max = 50))
- x <- rasterize(coords, r)
- f <- focal(x, w=matrix(1, nc=3, nr=3), na.rm=TRUE)
- rr <- mask(r, f)
- slope <- terrain(rr, "slope")
- extract(a, coords)
- # [1] 0.0019366236 0.0020670699 0.0006305257 0.0025334280 0.0023480935 0.0007527267 0.0002699272 0.0004699626
- # [9] 0.0004869054 0.0025651333 0.0010415805 0.0008574920 0.0010664869 0.0017700297 0.0001666226 0.0008405391
- #[17] 0.0017682167 0.0009854172 0.0015350466 0.0017714466 0.0012994945 0.0016563132 0.0003276584 0.0020499529
- #[25] 0.0006582073
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement