
General utility functions for working with distance units objects
Source:R/is_dist_units.R
is_dist_units.Rdis_dist_units(): Is x a distance unit object?is_diff_dist(): What is the difference between x and y distance?is_same_dist(): Is x the same distance as y? or does the bbox of x and bbox of y have the same x, y, or diagonal distance?is_shorter(),is_longer(): Is x shorter or longer than y?is_same_area(): do x and y have the same area?is_same_units(): are x and y character strings that represent the same units or objects that use the same units?
Usage
is_dist_units(x)
is_diff_dist(x, y, units = NULL)
is_same_dist(x, y, dist = NULL, diff = FALSE, call = caller_env(), ...)
is_longer(x, y)
is_shorter(x, y)
get_dist_units(x, allow_null = TRUE, multiple = TRUE, quiet = FALSE)
as_dist_units(x, units = NULL, allow_null = FALSE, call = caller_env())
is_diff_area(x, y, units = NULL, combine = TRUE)
is_same_area(x, y, units = NULL, combine = TRUE, diff = FALSE, ...)
is_same_units(x, y = NULL)Arguments
- x, y
objects to check
- units
For is_diff_dist, if x and y are both not units objects, use units; default to
NULL.- dist
type of distance to compare if x and y are
sf,sfc, orbboxobjects; "diagdist", "xdist", "ydist". defaults toNULL.- diff
If
TRUE, return results from is_diff_dist or is_diff_area; ifFALSE, return logical indicator; defaults toFALSE- call
The execution environment of a currently running function, e.g.
caller_env(). The function will be mentioned in error messages as the source of the error. See thecallargument ofabort()for more information.- ...
Additional parameters passed to
all.equal()- allow_null
If allow_null is
TRUE, allow x to return aNULLvalue; ifFALSE, error onNULLvalues.- multiple
If
TRUEand x is a character vector with distance/area units, get_dist_units may return multiple units. Passed to rlang::arg_match.- quiet
If
TRUE, suppress warning messages.- combine
If
TRUE, combine objects withsf::st_combine()before comparing area withis_diff_area()oris_same_area(), defaults toTRUE.
Details
There are two additional functions that support these utility functions:
get_dist_units(): Get the distance units from x (if x is a sf or units objects or a character string from dist_unit_options)as_dist_units(): Convert x to units using units::as_units
See also
Other dist:
compare_dist(),
convert_dist_scale(),
convert_dist_units(),
get_measurements,
sf_bbox_dist()