Set raster extent to physical units
Arguments
- raster
A
SpatRasterwith hyperspectral data.- reference
A
SpatVectorwith a single point in pixel space that marks the physical origin anchor on the vertical axis.- um_per_pixel
Numeric. Physical size of one pixel in µm.
- origin
Numeric. Physical position assigned to
referencein µm. Default0.- units
Character. Output units for the calibrated raster extent. One of
"um","mm", or"cm". Default"cm".
Value
A SpatRaster with a physically calibrated
extent.
Details
This keeps the current raster values unchanged, but updates the spatial extent so that downstream plotting and profile extraction work in physical units.
The calibration is linear: the raster grid is converted from pixels to
physical units using the supplied micrometers-per-pixel ratio. The
horizontal axis starts at the first cell centre, and the vertical axis is
anchored to reference at origin.
Importantly, at this stage, calibration metag does not carry forvard into analysis products. Calibrate immediate products, where real world units are necessary.
See also
hsi_calibration_from_scale(), hsi_calibration_direct(),
hsi_calibration_from_dims() for obtaining um_per_pixel.
hsi_pixels_to_units() for direct conversion of pixel positions.
Other HSI Calibration:
hsi_calibration_direct(),
hsi_calibration_from_dims(),
hsi_calibration_from_scale(),
hsi_drop_crs(),
hsi_pixels_to_units()
Examples
if (FALSE) { # \dontrun{
x <- terra::rast("REFLECTANCE_testdata.tif")
# Anchor point in pixel space, e.g. the core top in the first column.
reference <- terra::vect(cbind(1, terra::nrow(x)), type = "points")
# 60 µm per pixel, supplied directly.
um <- hsi_calibration_direct(60)
x_cal <- hsi_set_extent(x, reference, um_per_pixel = um, units = "cm")
} # }