Compare a distance to the dimension of a bounding box or another distance value
Source:R/compare_dist.R
compare_dist.Rd
Compare dist to a distance based on x. If to is "xdist" (default), "ydist",
"diagdist", or any length 2 character vector supported by sf_bbox_dist()
dist is compared to the resulting distance. If to is an sf or sfc object, the
comparison distance is the results from sf::st_distance()
with x as the
first parameter and to as the second. x can also be a numeric value with or
without a units class. Use the "how" argument to determine the type of
comparison: "ratio" (dist divided by comparison distance) "fit" (how many
lengths of dist can fit wholly within the comparison distance) "longer",
"shorter", "same" (uses tolerance parameter).
Arguments
- dist
Distance to check as a units class or numeric vector
- x
A
sf
,sfc
, orbbox
object or a numeric vector.- units
Units to compare. If dist or x are numeric they are assumed to be in the provided units or the units of the coordinate reference system (CRS) for x (if x is a
sf
,sfc
, orbbox
object).- to
Distance to compare dist with. Standard options include "xdist" (default), "ydist", or "diagdist" to compare to
sf_bbox_xdist()
,sf_bbox_ydist()
, orsf_bbox_diagdist()
. If to is a length 2 character vector, x, to, and any ... parameters are passed tosf_bbox_dist()
. If to is an sf or sfc object, to and any additional ... parameters are passed tosf::st_distance()
using x as the first argument and to as the second. If x is a numeric vector the value of to is ignored.- how
If "ratio", dist divided by the comparison distance. If what is "fit", return the number of times dist fits in the comparison distance without remainder. If "longer", "shorter", "same", return a logical vector.
- tolerance
passed to
all.equal()
ifhow = "same"
- ...
Additional parameters passed to
sf::st_distance()
if to is an sf or sfc object orsf_bbox_dist()
if to is a length 2 character vector.
See also
Other dist:
convert_dist_scale()
,
convert_dist_units()
,
get_measurements
,
is_dist_units()
,
sf_bbox_dist()