cubePlot: cubePlot

Description Usage Arguments Note Author(s) See Also Examples

View source: R/plot_HyperSpec_cube.R

Description

Plotting 3D cube of hyperspectral data using rgl-package

Usage

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

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.

...

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## 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 Dec. 14, 2017, 5:16 p.m.