# approx_distances: Approximate distances In tmaptools: Thematic Map Tools

## Description

Approximate distances between two points or across the horizontal and vertical center lines of a bounding box.

## Usage

 ```1 2``` ```approx_distances(x, y = NULL, projection = NULL, target = "metric", orig = NA, to = NA, show.warnings = TRUE) ```

## Arguments

 `x` object that can be coerced to a bounding box with `bb`, or a pair of coordinates (vector of two). In the former case, the distance across the horizontal and vertical centerlines of the bounding box are approximated. In the latter case, `y` is also required; the distance between points `x` and `y` is approximated. `y` a pair of coordintes, vector of two. Only required when `x` is also a pair of coordintes. `projection` projection code, needed in case `x` is a bounding box or when `x` and `y` are pairs of coordinates. See `get_proj4` `target` target unit, one of: `"m"`, `"km"`, `"mi"`, and `"ft"`. `orig` original unit, i.e. by which `x` is defined. Only needed if this information is missing from `x` and `x` is projected. Options: `"m"`, `"km"`, `"mi"`, and `"ft"`. `to` multiplier used as follows: `orig * to = target`. Only needed when `orig` or `target` is unknown. For instance, if `target` is set to `"hm"` (hectometer), and `orig` is `"m"`, then `to` should be 100, meaning 1 hectometer equals 100 meters. `show.warnings` should warnings be shown?

## Value

If `y` is specified, a list of two: unit and dist. Else, a list of three: unit, hdist (horizontal distance) and vdist (vertical distance).

## References

Tennekes, M., 2018, tmap: Thematic Maps in R, Journal of Statistical Software, 84(6), 1-39, DOI

`projection_units` and `approx_areas`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21``` ```## Not run: if (require(tmap)) { data(NLD_prov) # North-South and East-West distances of the Netherlands approx_distances(NLD_prov) # Distance between Maastricht and Groningen p_maastricht <- geocode_OSM("Maastricht")\$coords p_groningen <- geocode_OSM("Groningen")\$coords approx_distances(p_maastricht, p_groningen) # Check distances in several projections sapply(c("wintri", "utm31", "laea_Eur", "rd", "longlat"), function(projection) { p_maastricht <- geocode_OSM("Maastricht", projection = projection)\$coords p_groningen <- geocode_OSM("Groningen", projection = projection)\$coords approx_distances(p_maastricht, p_groningen, projection = projection) }) } ## End(Not run) ```