cubePlot: cubePlot

View source: R/plot_HyperSpec_cube.R

cubePlotR Documentation

cubePlot

Description

Plotting 3D cube of hyperspectral data using rgl-package

Usage

cubePlot(x, r, g, b, ncol = 1, nrow = 1, 
         sidecol = colorRamp(palette(heat.colors(100))), 
         z_interpolate = FALSE, ...)

Arguments

x

Object of class Speclib.

r

Integer. Index of band used as red channel. If omitted, the band closest to 680 nm is selected.

g

Integer. Index of band used as green channel. If omitted, the band closest to 540 nm is selected.

b

Integer. Index of band used as blue channel. If omitted, the band closest to 470 nm is selected.

ncol

Integer giving the column(s) in x which is/are used to plot the spectral dimension.

nrow

Integer giving the row(s) in x which is/are used to plot the spectral dimension.

sidecol

ColorRamp used to illustrate spectral dimension.

z_interpolate

Interpolate spectral dimension. This is useful if a cube is plotted which has a much larger spatial compared to spectral dimension. If TRUE the spectral dimension will be interpolated to the minimum of the spatial dimension. Alternatively, an integer value may be passed.

...

Further arguments passed to plotRGB for the top of the cube. Currently, the following two arguments are supported:

  • scale: Maximum (possible) value in the three channels. Defaults to the maximum value in the red, green and blue band selected by arguments r, g and b.

  • stretch: Option to stretch the values to increase the contrast of the image: "lin" (default) or "hist"

Note

The function may take a lot of time if the images are large. Consider plotting a subset of the entire image instead of plotting the entire image. Please note that the example below demonstrates the functionality with a very small image.

For unknown reasons, it may be necessary to execute the function twice in order to get the right colors at the walls of the cube.

Author(s)

Lukas Lehnert

See Also

Speclib

Examples

## Not run: 
## Create raster file using PROSPECT D
## Run PROSPECT for 1600 random chlorophyll content values
parameter <- data.frame(Cab = round(runif(1600, min = 10, max = 40), 0))
spectra <- PROSPECT(parameterList = parameter)
## Create SpatialPixelsDataFrame and fill data with spectra from PROSPECT
rows <- round(nspectra(spectra)/40, 0)
cols <- ceiling(nspectra(spectra)/rows)
grd <- SpatialGrid(GridTopology(cellcentre.offset = c(1,1,1),
cellsize = c(1,1,1),
cells.dim = c(cols, rows, 1)))
x <- SpatialPixelsDataFrame(grd, data = as.data.frame(spectra(spectra)))
## Write data to example file (example_in.tif) in workingdirectory
writeGDAL(x, fname = "example_in.tif", drivername = "GTiff")

## Read the raster and plot 3D cube
wavelength <- wavelength(spectra)
ras <- speclib("example_in.tif", wavelength)

cubePlot(ras)

## End(Not run)

hsdar documentation built on March 18, 2022, 6:35 p.m.