as_unit: Transform distance and area values

View source: R/adj-aZ.R

as_meterR Documentation

Transform distance and area values

Description

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

Usage

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.

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 set to TRUE informative messages regarding the computational progress will be printed.

(Warning messages will always be printed.)

Details

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

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.

Examples


library(SPATA2)
library(SPATAData)

object <- downloadSpataObject("269_T")

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)



kueckelj/SPATA2 documentation built on March 16, 2024, 10:25 a.m.