How can get duration from a departure column and an arrival column The values of the columns are geographical coordinates, attitude and longitude. the api provides a function (ors_matrix) to calculate and return matrice.
more details about ors_matrix function: https://giscience.github.io/openrouteservice-r/articles/openrouteservice.html#matrix-1
coordinates <- list(
c(9.970093, 48.477473),
c(9.207916, 49.153868),
c(37.573242, 55.801281),
c(115.663757,38.106467)
)
query for duration and distance in km
res <- ors_matrix(coordinates, metrics = c("duration"), units = "km")
duration in hours
(res$durations / 3600) %>% round(1)
will return this result:
[,1] [,2] [,3] [,4]
[1,] 0.0 1.6 24.2 109.5
[2,] 1.6 0.0 24.0 109.3
[3,] 24.2 24.0 0.0 86.3
[4,] 109.9 109.7 86.5 0.0
How can get the duration between 2 points with multiple entries (using csv file foramated as bellow)
We consider this Table_Geo with 2 entries:
lat_1 long_1 lat_2 long_2 duration
----------------------------------------------------------------
43.197008 2.316883 48.232163 4.705054 ??
43.320271 1.95256 48.51684 3.731011 ??