panel_raster: Add raster to the image panel

panel_rasterR Documentation

Add raster to the image panel

Description

If specified image has 3 or 4 bands, then color composite is plotted on image panel, else the image is plotted regarding to its color table.

Usage

panel_raster(...)


Arguments

...

Set of arguments, which are recognized via their names (using regular expressions) and classes.
1. Passed to colorize.
2. interpreted in this function:

"(^$|obj)" as obj

Object of class ursaRaster. Raster band for plotting. Multiple bands are allowed if then can be interpreted as RGB or RGBA.

"useRaster" as useRaster

Logical. If TRUE then a bitmap raster is used to plot the image instead of polygons. See argument useRaster in function image. Default depends on PNG device (getOption("ursaPngDevice"), which is set up in compose_open); it is TRUE for "cairo" device, and FALSE for "windows" device.

"interp(olate)*" as interpolate

Logical. Passed as argument interpolate to function rasterImage.

"(alpha|transp(aren(cy)*)*)" as alpha

Numeric or character. Level of transparency. If numeric, the either ⁠0 <= alpha <= 1⁠ or 0 <= alpha <= 255. If character, then one byte of hexadecimal value ⁠"00" <= alpha <= "FF"⁠. If NA, then transparency is used from colortable, else transparency of colortable is overwritten by alpha. Default is NA.

"verb(ose)*" as verbose

Logical. Value TRUE may provide some additional information on console. Default is FALSE.

Details

If obj is list of raster images, then panel_raster is applied to each item of list, and colortable of last item is returned.

If obj has 3 or 4 bands then obj is interpreted as RGB(A) image.

Function attempts to speed up plotting by reduce image matrix for big rasters.

Value

If argument obj has strictly one band, then function returns color table - object of class ursaColorTable, which can be used as an input argument for the colorbar legend (function legend_colorbar). Otherwise function returns NULL value.

Author(s)

Nikita Platonov platonov@sevin.ru

Examples

session_grid(NULL)
# example no.1 -- direct use
session_grid(regrid(mul=1/32))
dima <- with(session_grid(),c(columns,rows,3))
a <- ursa_new(value=array(runif(prod(dima),min=127,max=255),dim=dima))
p <- colorize(a,pal=c("black","white"),ramp=TRUE,value=0:256)
compose_open(layout=c(2,3),skip=4,legend=list(list("top","full"),list("bottom",2:3)))
for (i in seq(6)) {
   panel_new()
   if (i<4)
      panel_raster(p[i])
   else
      panel_raster(a,interpolate=i==5)
   panel_decor(col="black",coast=FALSE)
   panel_annotation(c("red","green","blue"
                    ,"interpolate=FALSE","interpolate=TRUE"))
}
legend_colorbar(p,label=seq(0,256,by=16),units="channels")
legend_mtext("color composite")
compose_close()

# example no.2 -- indirect use
ps <- pixelsize(NULL)
display(ps,raster.verb=TRUE)

# example no.3 -- color table for legend
session_grid(NULL)
compose_open()
panel_new()
ct <- panel_raster(ps,pal=terrain.colors)
panel_decor()
compose_legend(ct)
compose_close()


ursa documentation built on Sept. 30, 2024, 9:35 a.m.