Collection of functions to transform distance and area values. If pixels are involved, additional SPATA2 specific content is needed.

as_meter(input, ...)

as_meter2(input, ...)

as_micrometer(input, ...)

as_micrometer2(input, ...)

as_millimeter(input, ...)

as_millimeter2(input, ...)

as_nanometer(input, ...)

as_nanometer2(input, ...)

as_pixel(input, object = NULL, ..., add_attr = TRUE)

as_unit(input, unit, object = NULL, round = FALSE, verbose = FALSE, ...)

as_centimeter(input, ...)

as_centimeter2(input, ...)

as_decimeter(input, ...)

as_decimeter2(input, ...)

Arguments

input

Values that represent spatial measures.

...

Needed arguments that depend on the input/unit combination. If one of both is 'px', argument object must be specified.

object

An object of class SPATA2 or, in case of S4 generics, objects of classes for which a method has been defined.

unit

Character value. Specifies the desired unit.

round

Numeric value or FALSE. If numeric, given to digits of base::round(). Rounds transformed values before they are returned.

verbose

Logical. If TRUE, informative messages regarding the computational progress will be printed.

(Warning messages will always be printed.)

Value

All functions return an output vector of the same length as the input vector.

If argument unit is among validUnitsOfLengthSI() or validUnitsOfAreaSI() the output vector is of class units. If argument unit is 'px', the output vector is a character vector or numeric vector if as_numeric is TRUE.

Details

For more information about area values, see details of ?is_area. Fore more information about distance values, see details of ?is_dist.

Examples


library(SPATA2)
library(tidyverse)

data("example_data")

object <- example_data$object_UKF275T_diet

containsPixelScaleFactor(object) # must be TRUE

pixel_values <- c(200, 450, 500)

si_dist_values <- c("2mm", "400mm", "0.2mm")

# spata object must be provided to scale based on current image resolution
as_millimeter(input = pixel_values, object = object, round = 2)

as_micrometer(input = pixel_values, object = object, round = 4)

as_pixel(input = si_dist_values, object = object)

# spata object must not be provided
as_micrometer(input = si_dist_values)