interpolate_sky_points: Interpolate sky points

View source: R/interpolate_sky_points.R

interpolate_sky_pointsR Documentation

Interpolate sky points


Interpolate values from canopy photographs.


interpolate_sky_points(sky_points, g, k = 3, p = 2, rmax = 200, col_id = "rl")



An object of class data.frame. The result of a call to extract_rl or extract_dn, or a data.frame with same basic structure and names.


SpatRaster built with sky_grid_segmentation or chessboard.


Numeric vector of length one. Number of k-nearest neighbors.


Numeric vector of length one. Power for inverse-distance weighting.


Numeric vector of length one. Maximum radius where to search for knn.


Numeric vector of length one. ID of the column with the values to interpolate.


This function use knnidw as workhorse function, so arguments k, p, and rmax are passed to it.

This method is based on \insertCiteLang2010;textualrcaiman. In theory, interpolation requires a linear relation between DNs and the amount of light reaching the sensor. To that end, photographs should be taken in RAW format to avoid gamma correction \insertCiteLang2010rcaiman. As a compromise solution, gbc can be used.

The vignetting effect also hinders the linear relation between DNs and the amount of light reaching the sensor. Please refer to \insertCiteLang2010;textualrcaiman for more details about the vignetting effect.

The use of k = 1 solves the linear dilemma from the theoretical point of view since no averaging is taking place in the calculations. However, probably, it is best to use k greater than 1.

Default parameters are the ones used by \insertCiteLang2010;textualrcaiman. The argument rmax should account for between 15 to 20 degrees, but it is expressed in pixels units. So, image resolution and lens projections should be taken into account to set this argument properly.

The argument g should be the same used to obtain sky_points. The result will be limited to the cells with at least one pixel covered by the convex hull of the sky points.


An object of class SpatRaster.



See Also

Other Sky Reconstruction Functions: cie_sky_model_raster(), fit_cie_sky_model(), fit_coneshaped_model(), fit_trend_surface(), fix_reconstructed_sky(), ootb_sky_reconstruction()


## Not run: 
caim <- read_caim() %>% normalize()
z <- zenith_image(ncol(caim), lens("Nikon_FCE9"))
a <- azimuth_image(z)
bin <- ootb_obia(caim, z, a)

g <- sky_grid_segmentation(z, a, 10)
r <- gbc(caim$Blue*255)
sky_points <- extract_sky_points(r, bin, g)
sky_points <- extract_rl(r, z, a, sky_points, NULL)
sky <- interpolate_sky_points(sky_points$sky_points, g)

#modify g if the goal is to get the whole sky
g <- !
sky <- interpolate_sky_points(sky_points$sky_points, g)

#restricted view canopy photo
path <- system.file("external/APC_0020.jpg", package = "rcaiman")
caim <- read_caim(path)
r <- gbc(caim$Blue)
caim <- normalize(caim)

bin <- ootb_obia(caim)

g <- chessboard(caim, 100)
sky_points <- extract_sky_points(r, bin, g)
sky_points <- extract_dn(r, sky_points)
sky <- interpolate_sky_points(sky_points, !, col_id = 3)

## End(Not run)

rcaiman documentation built on Sept. 20, 2022, 1:05 a.m.