Description Usage Arguments Value Examples
Calculate distance between two GeoJSON points
1 | 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 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")
|
[1] 97.15958
[1] 60.37218
[1] 0.8735029
[1] 0.0152455
[1] 146.5956
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.