Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. # make 2 rasters of the same extent, different resolutions
  2. ext <- extent(0,1000,0,1000)
  3. r1 <- raster(nrows=1000, ncols=1000,ext)
  4. r1[] <- sample(seq(from = 1, to = 6, by = 1), size = 1000000, replace = TRUE)
  5. r2 <- raster(nrows=10, ncols=10,ext)
  6. r2[] <- sample(seq(from = 0, to = 1, by = 0.05), size = 100, replace = TRUE)
  7. # create areas of interest in coarser raster
  8. r2[r2 < 0.9] <- NA
  9.  
  10. # disaggregate the coarser raster to the same res as the finer raster
  11. r2 <- disaggregate(r2,fact=c(100,100))
  12. # mask the fine by the coarse
  13. r3 <- mask(r1,r2)
  14. # and return a frequency table of the finer resolution
  15. freq(r3,useNA="no")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement