I found a solution to my problem, working mainly in R:
First, you will need to clone https://github.com/Project-OSRM/osrm-backend. Then you will need to install and launch docker https://www.docker.com/community-edition
country <- "germany"
# Download new maps - NOTE, this is a large download (more than 3GB)
download.file(url = paste0("http://download.geofabrik.de/europe/", country, "-latest.osm.pbf"),
destfile = paste0("./Data/POIs/", country, "/latest.osm.pbf"))
# Download dictionary
download.file(url = "https://raw.githubusercontent.com/MorbZ/OsmPoisPbf/master/doc/poi_types.csv",
destfile = paste0("./Data/POIs/", country, "/poi_types_dict.csv"))
pois_dict <- read.csv(paste0("./Data/POIs/", country, "/poi_types_dict.csv", sep = ","))
pois_dict <- pois_dict[!is.na(pois_dict$CODE), ]
# Create local version of search engine car + foot
cmd1 <- paste0("cd ",getwd(),"/Data/POIs/", country)
cmd2 <- paste0("docker run -t -v $(pwd):/data osrm/osrm-backend osrm-extract -p /opt/car.lua /data/latest.osm.pbf")
cmd3 <- paste0("docker run -t -v $(pwd):/data osrm/osrm-backend osrm-contract /data/latest.osrm")
cmd4 <- paste0("docker run -t -i -p 5000:5000 -v $(pwd):/data osrm/osrm-backend osrm-routed /data/latest.osrm")
system(paste(cmd1, cmd2, cmd3, cmd4, sep = "; "))
Then you are able to call the following line (update the longitude latitudes as needed)
txt <- getURL("http://127.0.0.1:5000/route/v1/driving/13.388860,53.517037;13.385983,52.496891?overview=false")
A few extra notes:
1) This is obviously for OSRM, but similar techniques can be used for OSM as well.
2) The file size might be to big, docker only allocates 1000Mb as default, you will need to change this depending on your requirements.
3) The final result obtained needs to be formated (with regular expressions) to get what you need.