| osrm_extract | R Documentation |
Run the osrm-extract tool to preprocess an OSM file
(.osm, .osm.bz2, or .osm.pbf) into the base .osrm graph files
using a specified Lua profile. After running, a companion
<base>.osrm.timestamp file must exist to confirm success.
osrm_extract(
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,
quiet = FALSE,
verbose = FALSE,
spinner = TRUE,
echo_cmd = FALSE
)
input_osm |
A string. Path to the input OSM file
( |
profile |
A string. Path to the OSRM Lua profile
(e.g. returned by |
threads |
An integer. Number of threads for
|
overwrite |
A logical. If |
verbosity |
A string. Log verbosity level passed to
|
data_version |
A string or |
small_component_size |
An integer. For
|
with_osm_metadata |
A logical. If |
parse_conditional_restrictions |
A logical. If |
location_dependent_data |
A string or |
disable_location_cache |
A logical. If |
dump_nbg_graph |
A logical. If |
quiet |
A logical. Master switch that suppresses package messages and
process output when |
verbose |
A logical. When |
spinner |
A logical. When |
echo_cmd |
A logical. When |
An object of class osrm_job with the following elements:
The path to the generated .osrm.timestamp file.
The directory containing all OSRM files.
The processx::run result object.
if (identical(Sys.getenv("OSRM_EXAMPLES"), "true")) {
# Install OSRM (temporary, session PATH)
install_dir <- osrm_install(
version = "latest",
path_action = "session",
quiet = TRUE
)
# copy example OSM PBF into a temporary workspace to avoid polluting pkg data
pbf_path <- system.file("extdata/cur.osm.pbf", package = "osrm.backend")
osrm_dir <- file.path(tempdir(), paste0("osrm-", Sys.getpid()))
dir.create(osrm_dir, recursive = TRUE)
tmp_pbf <- file.path(osrm_dir, "cur.osm.pbf")
file.copy(from = pbf_path, to = tmp_pbf, overwrite = TRUE)
# Find the path to the profile first
car_profile <- osrm_find_profile("car.lua")
# extract OSRM graph files
result <- osrm_extract(
input_osm = tmp_pbf,
profile = car_profile,
overwrite = TRUE,
threads = 1L
)
# path to generated .osrm files (specifically, the .osrm.timestamp file)
result$osrm_job_artifact
# Clean up binaries and workspace
osrm_uninstall(
dest_dir = install_dir,
clear_path = TRUE,
force = TRUE,
quiet = TRUE
)
unlink(osrm_dir, recursive = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.