ootb_interpolate_and_merge: Interpolate sky data into a raster and merge it with a sky...

View source: R/ootb_interpolate_and_merge.R

ootb_interpolate_and_mergeR Documentation

Interpolate sky data into a raster and merge it with a sky model raster

Description

This function is part of the efforts to automate the method proposed by \insertCiteLang2010;textualrcaiman. A paper for thoroughly presenting and testing this pipeline is under preparation.

Usage

ootb_interpolate_and_merge(
  r,
  z,
  a,
  sky_points,
  ootb_sky,
  rmax_tune = 1,
  use_window = TRUE
)

Arguments

r

SpatRaster. Typically, the blue channel extracted from a canopy photograph. The image from which sky_points was obtained.

z

SpatRaster built with zenith_image().

a

SpatRaster built with azimuth_image().

sky_points

The output of extract_sky_points() or an object of the same class and structure.

ootb_sky

An object of the class list that is the result of calling ootb_fit_cie_sky_model().

rmax_tune

Numeric vector of length one. It must be a positive integer. It is used to fine tune the rmax argument that is computed internally (see Details).

use_window

Logical vector of length one. If TRUE, a window of 3 \times 3 pixels will be used to extract the digital number from r.

Value

An object of class SpatRaster.

References

\insertAllCited

See Also

Other Sky Reconstruction Functions: cie_sky_image(), fit_cie_sky_model(), fit_coneshaped_model(), fit_trend_surface(), interpolate_sky_points(), ootb_fit_cie_sky_model()

Examples

## Not run: 
caim <- read_caim()
r <- caim$Blue
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)

path <- system.file("external/ootb_sky.txt", package = "rcaiman")
ootb_sky <- read_ootb_sky_model(gsub(".txt", "", path), z, a)

sky <- ootb_interpolate_and_merge(r, z, a, ootb_sky$sky_points, ootb_sky)

plot(sky$sky)

# See fit_cie_sky_model() for details on below file
path <- system.file("external/sky_points.csv",
                    package = "rcaiman")
sky_points <- read.csv(path)
sky_points <- sky_points[c("Y", "X")]
colnames(sky_points) <- c("row", "col")
head(sky_points)
plot(caim$Blue)
points(sky_points$col, nrow(caim) - sky_points$row, col = 2, pch = 10)

sky_points <- rbind(sky_points, ootb_sky$sky_points[, c("row", "col")])

sky <- ootb_interpolate_and_merge(r, z, a, ootb_sky$sky_points,
                             ootb_sky)
plot(sky$sky)

## End(Not run)

GastonMauroDiaz/rcaiman documentation built on April 14, 2025, 9:39 a.m.