Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

batchosrm: Access to the OpenStreetMap-based routing service OSRM for fast route extraction

An interface between R and the OSRM API. OSRM is a routing service based on OpenStreetMap data.

This package enables the fast computation of routes and is a much faster alternative to repeated calls to osrm::osrmRoute().

Installation

You can install the development version of batchosrm with:

remotes::install_github("rCarto/batchosrm")

Example

library(tictoc)
library(batchosrm)
x <- read.csv(system.file("csv/berlin.csv", package = "batchosrm"))
tic(msg = "Query durations, distances and geometries")
res <- routes(
  x = x[1:2000,],
  overview = TRUE,
  max_radius = 1000,
  nc = 8,
  nq = 150,
  server = "http://0.0.0.0:5000/",
  profile = "car"
)
toc()
#> Query durations, distances and geometries: 4.228 sec elapsed

library(sf)
#> Linking to GEOS 3.13.1, GDAL 3.10.3, PROJ 9.6.0; sf_use_s2() is TRUE
library(mapsf)
mf_theme("dracula")
st_transform(res, "EPSG:3035") |>
  mf_map(col = "#ffffff05", lwd = 1.2)
mf_title("Berlin")

tic(msg = "Query only durations and distances")
rex <- routes(
  x = x[1:2000,],
  overview = FALSE,
  max_radius = 1000,
  nc = 8,
  nq = 150,
  server = "http://0.0.0.0:5000/",
  profile = "car"
)
toc()
#> Query only durations and distances: 2.709 sec elapsed
rex[1:5,]
#>      duration distance
#> [1,]    21.39    12.70
#> [2,]    34.23    19.49
#> [3,]    20.74     9.60
#> [4,]    11.05     4.81
#> [5,]    14.85    11.56

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages