Description Usage Arguments Value See Also Examples
View source: R/approx_distances.R
Approximate distances between two points or across the horizontal and vertical centerlines of a bounding box.
1 | approx_distances(x, y = NULL, projection = NULL, target = NULL)
|
x |
object that can be coerced to a bounding box with |
y |
a pair of coordintes, vector of two. Only required when |
projection |
projection code, needed in case |
target |
target unit, one of: |
If y
is specifyed, a list of two: unit and dist. Else, a list of three: unit, hdist (horizontal distance) and vdist (vertical distance).
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, projection = 4326, target = "km")
# Check distances in several projections
sapply(c(3035, 28992, 4326), 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.