make_raster_lut: Make a raster LUT which is essentially a lookup table that...

View source: R/raster.R

make_raster_lutR Documentation

Make a raster LUT which is essentially a lookup table that for a given location points to the nearest non-mask value in a mask.

Description

Each cell of a lut contains a cell address of the closest cell covered by a non-mask value in the input. Obviously, cells already covered by non-mask will have it's original cell number. Cells covered by mask_value in the input will have a cell number of the closest non-mask cell.

Usage

make_raster_lut(
  x = make_dummy_mask(),
  mask_value = NA_real_,
  nonreassigned_value = "cellnumber"
)

Arguments

x

raster mask

mask_value

numeric the value of masked areas, by default NA

nonreassigned_value

either "cellnumber" which indicates cell number should be used or some numeric value like NA.

Details

Note this assigns the closest cell value which is a 1-d index into 2-d space.

Value

raster of cell addresses. Where the input, R, had non-mask values the cell addresses point to the input cell. Where the input had mask-valued cells, the output cell addresses point to the nearest non-mask cells in the input.

Examples

## Not run: 
library(terra)
mask <- make_dummy_mask()
lut <- make_raster_lut(mask)
z <- c(mask, lut)
names(z) <- c("mask", "lut")
plot(z)

## End(Not run)

BigelowLab/rasf documentation built on July 18, 2022, 10:19 p.m.