zenith_azimuth_from_row_col: Map between zenith–azimuth angles and raster coordinates

View source: R/zenith_azimuth_from_row_col.R

zenith_azimuth_from_row_colR Documentation

Map between zenith–azimuth angles and raster coordinates

Description

Bidirectional helpers to convert between angular coordinates on the hemispherical image (zenith, azimuth) and raster coordinates (row, col).

Usage

zenith_azimuth_from_row_col(z, a, row, col)

row_col_from_zenith_azimuth(z, a, zenith, azimuth)

Arguments

z

terra::SpatRaster generated with zenith_image().

a

terra::SpatRaster generated with azimuth_image().

row, col

numeric vectors. raster coodinates. Must have equal length.

zenith, azimuth

numeric vectors. Angles in degrees. Must have equal length.

Details

⁠zenith, azimuth⁠⁠row, col⁠. A sparse set of valid sky points is sampled over the image and enriched with their angular coordinates. Two local least-squares surfaces (spatial::surf.ls, np = 6) are fitted to predict row and col as smooth functions of (azimuth, zenith). Predictions are rounded to the nearest integer index. Out-of-bounds indices are not produced under normal conditions; clamp externally if needed.

⁠row, col⁠⁠zenith, azimuth⁠. Angles are obtained by direct lookup on z and a using terra::cellFromRowCol. If any queried cell is NA (e.g., outside the calibrated lens footprint), a synthetic z is reconstructed from the lens model attached to z (attribute lens_coef), and a is rebuilt with azimuth_image() using the stored orientation attribute in a. This yields robust angle retrieval near borders.

Value

See Functions

Functions

row_col_from_zenith_azimuth

Return image indices for given angles.

zenith_azimuth_from_row_col

Return angles in degrees for given image indices.

Examples

z <- zenith_image(1000, lens())
a <- azimuth_image(z)

rc <- row_col_from_zenith_azimuth(z, a, zenith = c(30, 60), azimuth = c(90, 270))
rc

ang <- zenith_azimuth_from_row_col(z, a, row = rc$row, col = rc$col)
ang

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