chart.from.tif: Selects each color of the calibration card

Usage Arguments Examples

View source: R/chart.from.tif.R

Usage

1
chart.from.tif(tif.path, samp.width = 0.01)

Arguments

tif.path
samp.width

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (tif.path, samp.width = 0.01) 
{
    file <- Sys.glob(path = paste0(tif.path, "vis/*.tif"))[1]
    vis.tiff <- readTIFF(file)
    vis.red <- raster(vis.tiff[, , 1])
    vis.green <- raster(vis.tiff[, , 2])
    vis.blue <- raster(vis.tiff[, , 3])
    rgb <- stack(vis.red, vis.green, vis.blue)
    options(warn = -1)
    op <- par(mfrow = c(1, 1), mar = c(0, 0, 0, 0), oma = c(0, 
        0, 0, 0))
    on.exit(par(op))
    plotRGB(rgb, scale = 1, asp = nrow(vis.red)/ncol(vis.red))
    options(warn = 0)
    chart.coords <- data.frame(x = numeric(), y = numeric())
    message("Click on all 24 color chart cells in sequence. The sequence follows left to right and starts at cell 1 (brown, top left) and finishes on cell 24 (black, bottom right).")
    for (i in 1:24) {
        options(warn = -1)
        chart.coords[i, 1:2] <- click(xy = T)[1:2]
        options(warn = 0)
    }
    sp.chart <- SpatialPoints(chart.coords)
    chart.buff <- gBuffer(sp.chart, width = samp.width, byid = T)
    plot(chart.buff, add = T, col = "green")
    return(chart.buff)
  }

united-ecology/photomoss documentation built on July 10, 2020, 10:21 p.m.