https://github.com/rrmn/distgeo_v
A blazing-fast tidyverse-friendly wrapper for geodesic distance calculation with R.
https://github.com/rrmn/distgeo_v
Last synced: about 1 month ago
JSON representation
A blazing-fast tidyverse-friendly wrapper for geodesic distance calculation with R.
- Host: GitHub
- URL: https://github.com/rrmn/distgeo_v
- Owner: rrmn
- License: lgpl-3.0
- Created: 2019-05-17T22:31:26.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-19T22:27:40.000Z (almost 7 years ago)
- Last Synced: 2026-01-01T14:36:43.193Z (5 months ago)
- Language: R
- Homepage:
- Size: 298 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# distGeo_v
A tidyverse-friendly wrapper for geosphere's geodesic distance calculation.
## Usage
library(geosphere)
source("https://raw.githubusercontent.com/RomanAbashin/distGeo_v/master/distGeo_v.R")
distGeo_v(x, y, xx, yy)
## Benchmarks


## Speed Test
library(tidyverse)
library(microbenchmark)
f_row <- function(t) {
result <- t %>%
rowwise() %>%
mutate(dist = distGeo(c(x, y), c(lag(x), lag(y))))
return(result)
}
f_vec <- function(t) {
result <- t %>%
mutate(dist = distGeo_v(x, y, lag(x), lag(y)))
return(result)
}
set.seed(1702)
for(i in c(1:10, 100, 1000, 10000)) {
n <- i
t <- tibble(x = runif(n, -180, 180),
y = runif(n, -60, 60))
mb <- microbenchmark(f_vec(t), f_row(t), unit = "ms")
tibble_mb <- cbind(data.frame(n = i), summary(mb))
if(i > 1) {
result_mb <- rbind(result_mb, tibble_mb)
} else {
result_mb <- tibble_mb
}
}