Download, Model and Analyze 'OpenStreetMap' Street Networks

A 'tidyverse'-friendly toolkit, inspired by the 'OSMnx' 'Python' library, to download, model, simplify, analyze and visualize street networks and other geospatial features from 'OpenStreetMap'. Build routable graphs from a place name, address, point or bounding box; simplify topology; compute shortest paths, isochrones and urban metrics (intersection density, circuity, street-orientation entropy, centrality); and export to 'sf', 'sfnetworks' and 'MapLibre'. Heavy graph computation is performed by a bundled 'Rust' core.


osmnxr osmnxr logo

CRAN status CRAN downloads License: MIT devel version R-CMD-check pkgdown

osmnxr is OSMnx for R: a tidyverse-friendly toolkit, inspired by the OSMnx Python library, to download, model, simplify, analyze and visualize street networks and other geospatial features from OpenStreetMap.

It is a reimplementation — not a Python wrapper. Heavy graph computation (routing, simplification, metrics) runs in a bundled Rust core via extendr, so there is no Python runtime to manage. Everything you get back is tidy sf.

Installation

osmnxr builds from source and needs the Rust toolchain (rustup) at install time.

# install.packages("remotes")
remotes::install_github("StrategicProjects/osmnxr")

Quick start

library(osmnxr)

# Download a drivable street network for a place
g <- ox_graph_from_place("Olinda, Brazil", network_type = "drive")
g
plot(g)

# Route between two points (Rust Dijkstra)
from <- ox_nearest_nodes(g, x = -34.85, y = -8.01)
to   <- ox_nearest_nodes(g, x = -34.84, y = -8.00)
ox_shortest_path(g, from, to)

# Urban metrics
ox_basic_stats(g)
ox_orientation_entropy(g)   # street-grid order/disorder

No network access? Explore the whole API offline with a synthetic grid:

g <- example_osm_graph()
ox_basic_stats(g)
ox_shortest_path(g, ox_nearest_nodes(g, 0, 0), ox_nearest_nodes(g, 300, 300))

How it works

osmnxr is split into a tidy R API over a Rust compute core:

osmnxr architecture

The pipeline, from a place name to an analyzable network:

osmnxr data flow

Related work

osmnxr complements the R geospatial stack — it can hand graphs to sfnetworks, tidygraph and dodgr, and downloads via the same Overpass API used by osmdata.

License

MIT © Andre Leite and contributors / StrategicProjects.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("osmnxr")

0.1.1 by Andre Leite, 3 months ago


https://github.com/StrategicProjects/osmnxr, https://strategicprojects.github.io/osmnxr/


Report a bug at https://github.com/StrategicProjects/osmnxr/issues


Browse source code at https://github.com/cran/osmnxr


Authors: Andre Leite [aut, cre] , Marcos Wasilew [aut] , Hugo Vasconcelos [aut] , Carlos Amorin [aut] , Diogo Bezerra [aut] , StrategicProjects [cph, fnd] , The extendr authors [cph] (Bundled Rust crates extendr-api , extendr-ffi , extendr-macros) , David Tolnay [cph] (Bundled Rust crates proc-macro2 , quote , syn , paste , readonly , unicode-ident) , Alex Crichton [cph] (Bundled Rust crate proc-macro2) , Marvin Loebel [cph] (Bundled Rust crate lazy_static) , Aleksey Kladov [cph] (Bundled Rust crate once_cell) , Unicode , Inc. [cph] (Bundled Rust crate unicode-ident (Unicode-3.0 data tables))


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports cli, glue, httr2, purrr, rlang, sf, tibble

Suggests dodgr, ggplot2, jsonlite, knitr, rmarkdown, sfnetworks, testthat, tidygraph, units, xml2

System requirements: Cargo (Rust's package manager), rustc


See at CRAN