raster.invert: Invert raster

View source: R/raster.invert.R

raster.invertR Documentation

Invert raster

Description

Inverts (flip) the values of a raster

Usage

raster.invert(x)

Arguments

x

A terra SpatRaster object

Details

Inverts raster values using the formula: (((x - max(x)) * -1) + min(x)

Value

A terra SpatRaster object with inverted (flipped) raster values

Author(s)

Jeffrey S. Evans <jeffrey_evans@tnc.org>

Examples

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)   


spatialEco documentation built on Nov. 18, 2023, 1:13 a.m.