Created
November 8, 2016 02:02
-
-
Save obrl-soil/cd7f1e9917138586532cc1e706dfbd9b to your computer and use it in GitHub Desktop.
relative values within a moving window
This file contains 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
library(raster) | |
r <- raster('path\\to\\your\\file.ext') | |
winmin <- function(x) min(x, na.rm = T) | |
winmax <- function(x) max(x, na.rm = T) | |
focalmin <- focal(r, w = matrix(1, ncol = 3, nrow = 3), winmin) | |
focalmax <- focal(r, w = matrix(1, ncol = 3, nrow = 3), winmax) | |
rel_el <- abs(focalmin - focalmax) | |
writeRaster(rel_el, file='path\\and\\output\\filename.ext') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment