Tests if input refers to an area using international area units according to the SPATA2 area framework.

  • is_area(): Tests if input can be interpreted as an area

  • is_area_si(): Tests if input can be interpreted as an area in SI units.

  • is_area_pixel(): Tests if input can be interpreted as an area in pixel.

is_area(input, error = FALSE)

is_area_pixel(input, error = FALSE)

is_area_si(input, error = FALSE)

Arguments

input

Character vector. Elements must match the requirements of the SPATA2 area framework. See details for more information.

Value

Logical vector of the same length as input and/or an error if verbose is TRUE.

Examples


library(SPATA2)

##### provide input as character vectors

# will return TRUE

is_area(input = c('2mm2', '4mm2'))

# will return FALSE

is_area(input = c('200 m2')) # space between value and unit

# will return TRUE

area_values <- c(200, 400)

area_values <- as_area(area_values, unit = "mm2")

is_area(input = area_values)

###### use units package

library(units)

area_values2 <- set_units(x = c(200, 300), value = "mm2")

is_area(area_values2)