as_meter | R Documentation |
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, ...)
input |
Values that represent spatial measures. |
... |
Needed arguments that depend on the input/unit combination. If
one of both is 'px', argument |
object |
An object of class |
unit |
Character value. Specifies the desired unit. |
round |
Numeric value or |
verbose |
Logical. If (Warning messages will always be printed.) |
For more information about area values, see details of ?is_area
. Fore
more information about distance values, see details of ?is_dist
.
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
.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.