Get road distances and routes with R, GraphHopper and OpenStreetMap.
Install rRoad within R with:
And follow the installation instructions from the INSTALL.md file in this repository.
After the installation process, you should be able to launch GraphHopper whenever you want from the command line with:
./graphhopper.sh web spain-latest.osm.pbf
spain-latest.osm.pbf should be the OpenStreetMap data file of your desired region.
With GraphHopper running, you can get results directly in R:
library(rRoad) pontevedra <- c(42.4338555, -8.6743651) coruna <- c(43.3618728, -8.4301933) roadRoute(from = pontevedra, to = coruna, weighting = "fastest", calc_points = FALSE)
Original idea: Création d’une matrice de distances routières avec des outils et des données libres (1/2) | R Géomatique by Timothée Giraud. You should check his OSRM R package for a more recent and better tool on this subject.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.