View source: R/raster.invert.R
raster.invert | R Documentation |
Inverts (flip) the values of a raster
raster.invert(x)
x |
A terra SpatRaster object |
Inverts raster values using the formula: (((x - max(x)) * -1) + min(x)
A terra SpatRaster object with inverted (flipped) raster values
Jeffrey S. Evans <jeffrey_evans@tnc.org>
library(terra)
r <- rast(nrows=500, ncols=500, xmin=571823, xmax=616763,
ymin=4423540, ymax=4453690)
crs(r) <- "epsg:9001"
r[] <- runif(ncell(r), 1000, 2500)
r <- focal(r, focalMat(r, 150, "Gauss") )
r.inv <- raster.invert(r)
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,2))
plot(r, main="original raster")
plot(r.inv, main="inverted raster")
par(opar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.