Colors: Helper for setting Raster or 'SpatRaster' colors

View source: R/plotting.R

ColorsR Documentation

Helper for setting Raster or SpatRaster colors

Description

This is a wrapper to help with migration to terra. Currently can only be used for a single layer SpatRaster or a RasterLayer.

Usage

Colors(ras, cols, n = NULL)

Arguments

ras

A ⁠Raster*⁠ or SpatRaster class object.

cols

a character vector of colours. See examples. Can also be a data.frame, see terra::coltab

n

A numeric scalar giving the number of colours to create. Passed to ⁠quickPlot::setColors(ras, n = n) <- ⁠. If missing, then n will be length(cols)

Examples


cols <- colorRampPalette(c("blue", "red"))(12)
ras <- terra::rast(matrix(1:100, 10, 10))
ras <- Colors(ras, cols)
terra::plot(ras)

ras <- raster::raster(matrix(1:100, 10, 10))
ras <- Colors(ras, cols)
raster::plot(ras)



PredictiveEcology/LandR documentation built on June 7, 2024, 4:16 p.m.