View source: R/sky_grid_segmentation.R
| sky_grid_segmentation | R Documentation |
Segment a hemispherical view into equal-angle bins in zenith and azimuth, assigning each pixel a grid-cell ID.
sky_grid_segmentation(z, a, angle_width, first_ring_different = FALSE)
z |
terra::SpatRaster generated with |
a |
terra::SpatRaster generated 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
|
first_ring_different |
logical vector of length one. If |
The intersection of zenith rings and azimuth sectors forms a grid whose cells
are circular trapezoids. By default, IDs encode both components as
sectorID * 1000 + ringID. If first_ring_different = TRUE, the zenith ring
is not subdivided.
The code below outputs a comprehensive list of valid values for angle_width.
For convenience, the column radians_denom can be used to provide
angle_width as 180 / radians_denom_i, where radians_denom_i is a value
taken from radians_denom.
df <- data.frame(degrees = 90 / 1:180)
deg_to_pi_expr <- function(deg) {
frac <- MASS::fractions(deg / 180)
strsplit(as.character(frac), "/")[[1]][2] %>% as.numeric()
}
df$radians_denom <- sapply(df$degrees, function(deg) deg_to_pi_expr(deg))
z <- zenith_image(10, lens())
a <- azimuth_image(z)
u <- c()
for (i in 1:nrow(df)) {
u <- c(u, tryCatch(is((sky_grid_segmentation(z, a,
180/df$radians_denom[i])), "SpatRaster"),
error = function(e) FALSE))
}
df <- df[u, ]
df
Single-layer terra::SpatRaster with integer labels. The
object carries attributes angle_width and first_ring_different.
sky_grid_centers(), ring_segmentation(), sector_segmentation()
caim <- read_caim()
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)
g <- sky_grid_segmentation(z, a, 15)
plot(g == 24005)
## Not run:
display_caim(g = g)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.