Learn R Programming

ursa (version 3.11.1)

as.raster: Export raster object to a colored representation.

Description

as.raster transforms object of class ursaRaster to the object of class raster (package grDevices)

Usage

# S3 method for ursaRaster
as.raster(x, ...)

Value

A raster object. It is a matrix. The values of matrix are colors.

Arguments

x

ursaRaster object

...

Set of arguments, which are recognized via their names (using regular expressions) and classes:

max

number giving the maximum of the color values range. Passed to function as.raster for S3 class 'array'. Default is 255.

Author

Nikita Platonov platonov@sevin.ru

See Also

as.array

Examples

Run this code
session_grid(NULL)
session_grid(regrid(mul=1/2))
a <- ursa_dummy(4,min=0,max=255)
a[a<70] <- NA
compose_open(layout=c(1,4),legend=NULL)
for (i in seq(4)) {
   panel_new()
   panel_plot(as.raster(a[seq(i)]),interpolate=FALSE)
   panel_annotation(paste("Number of channels:",i))
}
compose_close()

op <- par(mfrow=c(2,2),mar=rep(0.5,4))
plot(as.raster(a[1:1]),interpolate=FALSE)
plot(as.raster(a[1:2]),interpolate=FALSE)
plot(as.raster(a[1:3]),interpolate=FALSE)
plot(as.raster(a[1:4]),interpolate=FALSE)
par(op)

Run the code above in your browser using DataLab