extract_rr: Extract digital numbers at sky points and normalize by...

View source: R/extract_rr.R

extract_rrR Documentation

Extract digital numbers at sky points and normalize by estimated zenith radiance

Description

Compute relative radiance at selected sky points by dividing their digital numbers (DN) by an estimated zenith DN.

Usage

extract_rr(r, z, a, sky_points, no_of_points = 3, use_window = TRUE)

Arguments

r

terra::SpatRaster. Raster supplying the DN values; must share rows and columns with the image used to obtain sky_points. DN must be linearly related to radiance. See read_caim_raw().

z

terra::SpatRaster generated with zenith_image().

a

terra::SpatRaster generated with azimuth_image().

sky_points

data.frame with columns row and col (raster coordinates).

no_of_points

numeric vector of length one or NULL. Number of near-zenith points used to estimate the zenith DN using inverse distance weighting (power = 2). If NULL, the zenith DN is forced to 1, so rr = dn.

use_window

logical of length one. If TRUE (default), use a 3 \times 3 local mean around each point; if FALSE, use only the central pixel.

Value

List with named elements:

zenith_dn

numeric. Estimated DN at the zenith.

sky_points

data.frame with columns row, col, a, z, dn, and rr (pixel location, angular coordinates, extracted DN, and relative radiance). If no_of_points is NULL, zenith_dn = 1 and dn = rr.

Examples

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

# See fit_cie_model() for details on the CSV 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)
rr <- extract_rr(caim$Blue, z, a, sky_points, 1)
points(rr$sky_points$col, nrow(caim) - rr$sky_points$row, col = 3, pch = 0)

## End(Not run)

rcaiman documentation built on Sept. 9, 2025, 5:42 p.m.