Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # make 2 rasters of the same extent, different resolutions
- ext <- extent(0,1000,0,1000)
- r1 <- raster(nrows=1000, ncols=1000,ext)
- r1[] <- sample(seq(from = 1, to = 6, by = 1), size = 1000000, replace = TRUE)
- r2 <- raster(nrows=10, ncols=10,ext)
- r2[] <- sample(seq(from = 0, to = 1, by = 0.05), size = 100, replace = TRUE)
- # create areas of interest in coarser raster
- r2[r2 < 0.9] <- NA
- # disaggregate the coarser raster to the same res as the finer raster
- r2 <- disaggregate(r2,fact=c(100,100))
- # mask the fine by the coarse
- r3 <- mask(r1,r2)
- # and return a frequency table of the finer resolution
- freq(r3,useNA="no")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement