0

Is there a way to perform geometric mean over rasters in r while accounting for NA's? Will the code below suffice? Was exploring methods for doing this iteratively using list.files, a forloop and a stack, but for now this will be enough.

(raster1*raster2)^(1/2)
  • 1
    How do you want to 'account' for NAs (approximate/replace or leave as-is)?. The above will return NA for NA cells. You might look to `terra::focal(` for options to proceed. – Chris Aug 17 '23 at 12:27
  • Thanks Chris. I want to keep the NA's so it is appropriate as is. Thank you for the terra::focal() option, it will be handy moving forward. – user11057680 Aug 17 '23 at 19:12
  • And interesting that mixed signs (positive/negative) work as values in the above in non-NA cells.. – Chris Aug 17 '23 at 19:45

0 Answers0