Time distance in months
Consider two rasters that show the month of the maximum value of a variable during the climatological mean annual cycle. Calculating the absolute difference between both rasters may yield values that range from 0 to 11 (type a). A more meaningful range that considers the circular nature of the annual cycle would range from 0 to 6 (type b). This function converts a raster of type (a) to type (b).
intFun.grid.phase(x)
x |
A raster object of type (a) |
A raster object of type (b)
library(raster) # make some data data <- runif(100,0,11) data <- matrix(data, ncol=10) data <- raster::raster(data) # convert raster of type (a) to type (b) data <- calc(data,intFun.grid.phase) plot(data) plot(data); text(data)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.