Create spatial calibration from a digitized scale reference
Source:R/hsi_calibration_from_scale.R
hsi_calibration_from_scale.RdCreate a spatial calibration by measuring a known-length reference digitized in GIS software. The function calculates pixel distance from the geometry and derives resolution from the provided physical distance.
Arguments
- x
A
SpatVectorrepresenting a digitized scale reference. Must be either a line geometry or exactly 2 points. CRS must beNULL(pixel coordinates).- distance
Numeric. Physical distance the reference represents. Single positive value. Default
10000.- units
Character. Units of the provided distance. One of
"um"(micrometers),"mm", or"cm". Default"um".
Details
The input SpatVector can be a line drawn along
the reference, or two points placed at the reference endpoints. CRS must be
NULL because coordinates are in pixel space.
See also
Other HSI Calibration:
hsi_calibration_direct(),
hsi_calibration_from_dims(),
hsi_drop_crs(),
hsi_pixels_to_units(),
hsi_set_extent()
Examples
if (FALSE) { # \dontrun{
scale_line <- terra::vect("scale.gpkg", layer = "scale")
calibration <- hsi_calibration_from_scale(
scale_line,
distance = 10,
units = "mm"
)
scale_points <- terra::vect("points.gpkg", layer = "scale_points")
calibration <- hsi_calibration_from_scale(
scale_points,
distance = 10000,
units = "um"
)
} # }