Created
October 30, 2017 23:57
-
-
Save johnbaums/43b87f4861c5dbe52edf72212fcd58ef to your computer and use it in GitHub Desktop.
Faster standard deviation of RasterStack objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rast_sd <- function(x) { | |
# x: a RasterStack | |
n <- nlayers(x) | |
m <- mean(x) | |
devsq <- (x - m)^2 | |
sqrt(sum(devsq)/(n-1)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment