geo_distance | R Documentation |
Calculate distance between two GeoJSON points
geo_distance(from, to, units = "kilometers")
from |
Origin Feature<Point> |
to |
Destination Feature<Point> |
units |
(character) Can be degrees, radians, miles, or kilometers (default) |
the distance, a single numeric value, in units given
in units
parameter
point1 <- '{
"type": "Feature",
"properties": {
"marker-color": "#f00"
},
"geometry": {
"type": "Point",
"coordinates": [-75.343, 39.984]
}
}'
point2 <- '{
"type": "Feature",
"properties": {
"marker-color": "#0f0"
},
"geometry": {
"type": "Point",
"coordinates": [-75.534, 39.123]
}
}'
geo_distance(point1, point2)
geo_distance(point1, point2, units = "miles")
geo_distance(point1, point2, units = "degrees")
geo_distance(point1, point2, units = "radians")
pt1 <- '{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
0.5,
0.5
]
}
}'
pt2 <- '{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [2, 2]
}
}'
geo_distance(pt1, pt2, units = "miles")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.