I want to extract the mean, min and max stats from latitude -50 to 0 and from 0 to 50 etc. No idea how to do this.
I would prefer using R for this as I have a lot of these to do.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
One solution (using R) is to create extent objects of the bounding boxes you're interested in, and then
crop() to that extent and use the
cellStats() function to extract the mean, min, max, sd, etc. for that region. Here's what that looks like in code:
library(raster) myraster = raster("PATH/TO/RASTER.tif") extmat1 = matrix(data = c(-180,180,-50,0), nrow = 2, ncol = 2, byrow = TRUE) extent1 = extent(extmat1) extmat2 = matrix(data = c(-180,180,0,50), nrow = 2, ncol = 2, byrow = TRUE) extent2 = extent(extmat2) r1 = crop(myraster, extent1) r2 = crop(myraster, extent2) max1 = cellStats(r1, stat = 'max') min2 = cellStats(r2, stat = 'min')
... and so on, for whatever stats you're interested in.