cubePlot
Plotting 3D cube of hyperspectral data using rgl-package
cubePlot(x, r, g, b, ncol = 1, nrow = 1,
sidecol = colorRamp(palette(heat.colors(100))),
z_interpolate = FALSE, ...)x |
Object of class |
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 |
nrow |
Integer giving the row(s) in |
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 |
... |
Further arguments passed to
|
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.
Lukas Lehnert
## 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)Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.