if_raster: Flexible conversion to SpatRaster object

View source: R/solartools.R

if_rasterR Documentation

Flexible conversion to SpatRaster object

Description

if_raster is used to permit flexibility in the use of SpatRasts, matrices or arrays in many functions.

Usage

if_raster(x, r)

Arguments

x

an R object

r

an R object

Value

if r is a SpatRaster, x is converted to a SpatRaster with the same attributes as r, otherwise returns x

Examples

r <- is_raster(dtm100m)
r1 <- if_raster(r, dtm100m)
r2 <- if_raster(r, r)
class(r1) # is a SpatRaster
class(r2) # is a matrix

ilyamaclean/microclima documentation built on Sept. 5, 2024, 8:37 p.m.