View source: R/compute_canopy_openness.R
| compute_canopy_openness | R Documentation |
Calculate canopy openness from a binarized hemispherical image with angular coordinates.
compute_canopy_openness(bin, z, a, m = NULL, angle_width = 10)
bin |
logical terra::SpatRaster with one layer. A binarized
hemispherical image. See |
z |
terra::SpatRaster generated with |
a |
terra::SpatRaster generated with |
m |
logical terra::SpatRaster with one layer. A binary mask with
|
angle_width |
numeric vector of length one. Angle in deg that must
divide both 0–360 and 0–90 into an integer number of segments. Retrieve a
set of valid values by running
|
Canopy openness is computed following the equation from \insertCiteGonsamo2011;textualrcaiman:
CO = \sum_{i = 1}^{N} GF(\phi_i, \theta_i) \cdot \frac{\cos(\theta_{1,i}) -
\cos(\theta_{2,i})}{n_i}
where GF(\phi_i, \theta_i) is the gap fraction in cell i,
\theta_{1,i} and \theta_{2,i} are the lower and upper zenith
angles of the cell, n_i is the number of cells in the corresponding
zenith ring, and N is the total number of cells.
When a mask is provided via the m argument, the equation is adjusted to
compensate for the reduced area of the sky vault:
CO = \frac{\sum_{i=1}^{N} GF(\phi_i, \theta_i) \cdot w_i}
{\sum_{i=1}^{N} w_i}
\quad \text{with} \quad
w_i = \frac{\cos(\theta_{1,i}) - \cos(\theta_{2,i})}{n_i}
The denominator ensures that the resulting openness value remains scale-independent. Without this normalization, masking would lead to underestimation, as the numerator alone assumes full hemispherical coverage.
Numeric vector of length one, constrained to the range [0, 1].
caim <- read_caim()
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)
m <- select_sky_region(z, 0, 70)
bin <- binarize_with_thr(caim$Blue, thr_isodata(caim$Blue[m]))
plot(bin)
compute_canopy_openness(bin, z, a, m, 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.