0

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.

Raster Map on R

1

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.

1
  • Jepson thank you this worked perfectly! Really appreciate it. – Tony Brown Jul 24 '19 at 15:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.