Prepare OSRM Graph for Routing (Extract + Partition/Contract)
Source:R/osrm_prepare_graph.R
osrm_prepare_graph.RdHigh-level wrapper that first runs osrm-extract on an OSM file
to produce the base .osrm graph, then prepares it for routing via
either the MLD pipeline (osrm-partition + osrm-customize) or the CH pipeline (osrm-contract).
Usage
osrm_prepare_graph(
input_osm,
profile = osrm_find_profile("car.lua"),
threads = 8L,
overwrite = FALSE,
verbosity = c("INFO", "NONE", "ERROR", "WARNING", "DEBUG"),
data_version = NULL,
small_component_size = 1000L,
with_osm_metadata = FALSE,
parse_conditional_restrictions = FALSE,
location_dependent_data = NULL,
disable_location_cache = FALSE,
dump_nbg_graph = FALSE,
algorithm = c("mld", "ch"),
balance = 1.2,
boundary = 0.25,
optimizing_cuts = 10L,
max_cell_sizes = c(128, 4096, 65536, 2097152),
echo_cmd = FALSE,
echo = TRUE,
spinner = TRUE
)Arguments
- input_osm
A string. Path to the input OSM file:
.osm,.osm.bz2, or.osm.pbf.- profile
A string. Path to the OSRM Lua profile (e.g. returned by
osrm_find_profile("car.lua")).- threads
An integer. Number of threads for extract and partition/contract; default
8.- overwrite
A logical. If
FALSE, stops if any existing.osrm*files matching the base name are found alongsideinput_osm. Set toTRUEto overwrite them.- verbosity
A string. Log verbosity for extract/partition/contract (one of
"NONE","ERROR","WARNING","INFO","DEBUG"); default"INFO".- data_version
A string or
NULL. Passed toosrm-extractvia-d; defaultNULL.- small_component_size
An integer. For extract & partition; default
1000.- with_osm_metadata
A logical. Adds
--with-osm-metadataduring extract; defaultFALSE.- parse_conditional_restrictions
A logical. Adds
--parse-conditional-restrictions; defaultFALSE.- location_dependent_data
A string or
NULL. Path to GeoJSON for extract; defaultNULL.- disable_location_cache
A logical. Adds
--disable-location-cache; defaultFALSE.- dump_nbg_graph
A logical. Adds
--dump-nbg-graph; defaultFALSE.- algorithm
A string. One of
"mld"(default) or"ch".- balance
A numeric. Balance for
osrm-partition; default1.2.- boundary
A numeric. Boundary percentage for
osrm-partition; default0.25.- optimizing_cuts
An integer. Optimizing cuts for
osrm-partition; default10.- max_cell_sizes
A numeric vector. Max cell sizes for
osrm-partition; defaultc(128,4096,65536,2097152).- echo_cmd
A logical. Print each command before running; default
FALSE.- echo
A logical. Stream stdout/stderr; default
TRUE.- spinner
A logical. Show spinner instead of live logs; default
TRUE.
Value
A list with elements:
- osrm_path
The normalized path to the final
.osrmbase. This can be passed over toosrm_start_server().- logs
A list of
processx::runresults for each stage:extract,partition/contract, andcustomize(if MLD).