View source: R/fit_trend_surface.R
fit_trend_surface | R Documentation |
Fits a trend surface to sky digital numbers using spatial::surf.ls()
as
the computational workhorse.
fit_trend_surface(sky_points, r, np = 6, col_id = "dn", extrapolate = FALSE)
sky_points |
|
r |
numeric terra::SpatRaster with one layer. Image from which
|
np |
degree of polynomial surface |
col_id |
numeric or character vector of length one. The name or position
of the column in |
extrapolate |
logical vector of length one. If |
This function models the variation in digital numbers across the sky dome
by fitting a polynomial surface in Cartesian space. It is intended to
capture smooth large-scale gradients and is more effective when called
via apply_by_direction()
.
List with named elements:
raster
terra::SpatRaster containing the fitted surface.
model
object of class trls
returned by spatial::surf.ls()
.
r2
numeric value giving the coefficient of determination (R^2
) of the fit.
## Not run:
caim <- read_caim()
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)
m <- !is.na(z)
r <- caim$Blue
bin <- binarize_by_region(r, ring_segmentation(z, 15), "thr_isodata") &
select_sky_region(z, 0, 88)
g <- sky_grid_segmentation(z, a, 10, first_ring_different = TRUE)
sky_points <- extract_sky_points(r, bin, g, dist_to_black = 3)
plot(bin)
points(sky_points$col, nrow(caim) - sky_points$row, col = 2, pch = 10)
sky_points <- extract_dn(r, sky_points, use_window = TRUE)
sky_s <- fit_trend_surface(sky_points, r, np = 4, col_id = 3,
extrapolate = TRUE)
plot(sky_s$raster)
binarize_with_thr(r/sky_s$raster, 0.5) %>% plot()
sky_s <- fit_trend_surface(sky_points, r, np = 6, col_id = 3,
extrapolate = FALSE)
plot(sky_s$raster)
binarize_with_thr(r/sky_s$raster, 0.5) %>% plot()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.