beginCluster()
r <- raster()
r[] <- 1:ncell(r)
x <- clusterR(r, sqrt, verbose=T)
f1 <- function(x) calc(x, sqrt)
y <- clusterR(r, f1)
s <- stack(r, r*2, r*3)
f2 <- function(x) calc(x, range)
z <- clusterR(s, f2)
pts <- matrix(c(0,0, 45,45), ncol=2, byrow=T)
d <- clusterR(r, distanceFromPoints, args=list(xy=pts))
values(r) <- runif(ncell(r))
m <- c(0, 0.25, 1, 0.25, 0.5, 2, 0.5, 1, 3)
m <- matrix(m, ncol=3, byrow=TRUE)
rc1 <- clusterR(r, reclassify, args=list(rcl=m, right=FALSE),
filename='rcltest.grd', datatype='INT2S', overwrite=TRUE)
# equivalent to:
rc2 <- reclassify(r, rcl=m, right=FALSE, filename='rcltest.grd', datatype='INT2S', overwrite=TRUE)
endCluster()
Run the code above in your browser using DataLab