An R Port of 'OSMnx' for 'OpenStreetMap' Street Networks

An R port of 'OSMnx', the 'Python' library by Geoff Boeing (Boeing, 2025, ), to download, model, simplify, analyze and visualize street networks and other geospatial features from 'OpenStreetMap'. The public interface, the modelling choices and the 'Overpass' queries are those of 'OSMnx', translated to a 'tidyverse'-friendly R interface; the port was written with the assistance of AI coding tools and is not affiliated with the 'OSMnx' project. 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 the bundled 'Rust' crate 'osmnxr-core'.


osmnxr osmnxr logo

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

osmnxr is an R port of OSMnx, the Python library created by Geoff Boeing, to download, model, simplify, analyze and visualize street networks and other geospatial features from OpenStreetMap. The interface, the modelling choices and the Overpass queries are OSMnx's, translated to a tidyverse-friendly R API: the design is Geoff Boeing's work, and this package is its translation. If you use osmnxr, please cite OSMnx.

osmnxr is an independent project: it is not affiliated with, maintained by or endorsed by the OSMnx project or its author. The port was written with the assistance of AI coding tools (see How this port was made).

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

Installation

Install the released version from CRAN (macOS and Windows binaries need no Rust; building from source needs the Rust toolchain, rustup, version 1.81 or later — the crates it depends on come with the package, nothing is downloaded):

install.packages("osmnxr")

Or the development version from GitHub (always builds from source):

# 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.

Citation

osmnxr is a port of OSMnx, so the work to cite is OSMnx:

Boeing, G. (2025). Modeling and Analyzing Urban Networks and Amenities with OSMnx. Geographical Analysis, 57(4), 567–577. doi:10.1111/gean.70009

citation("osmnxr") gives this reference first, followed by the entry for the R package itself.

How this port was made

osmnxr translates OSMnx (MIT, © Geoff Boeing) to R: function names (graph_from_place becomes ox_graph_from_place()), network types, default settings, the Overpass filters (reproduced tag for tag), topology simplification, intersection consolidation and the urban metrics all follow the original, and each release is checked for parity against OSMnx. The translation was done by the package authors with the assistance of AI coding tools; the R code and the Rust core were written for this package rather than copied line by line, but the intellectual contribution of the design is that of OSMnx's author. The OSMnx copyright and license notice ships with the package in inst/COPYRIGHTS.

A few things are not in OSMnx and are this package's own: Pareto-optimal and constrained routing, travelling-salesman routes, ox_union()/ox_blend(), isochrones, and the converters to sfnetworks, tidygraph, dodgr and MapLibre. Differences from OSMnx's behaviour are bugs in the port: please report them here, not to the OSMnx project.

Acknowledgements

To Geoff Boeing, for OSMnx and for a decade of maintaining it in the open. With his consent, he is listed in the package DESCRIPTION as author and copyright holder of the original work; the package authors are the translators and maintainers of the R port. The data come from the OpenStreetMap contributors and the public Overpass and Nominatim services.

Thanks to everyone who files issues — user reports shape this package. Srikanth Komala Sheshachala (@talegari) proposed ox_union() for multimodal routing (#1), ox_route_tsp() for travelling-salesman routes (#4), constrained / Pareto-optimal routing with road preferences (#5) and ox_blend() for snapping points and whole graphs into a network (#6); his careful reports with reproducible benchmarks also led to automatic retries on transient Overpass failures (#2), a ~250× faster graph-building phase on metro-sized extracts (#3), and the session edge-index cache plus the ox_route_shortest() interface (#5 feedback).

License

MIT © André Leite and contributors / StrategicProjects. OSMnx, which this package ports, is MIT © 2016–2026 Geoff Boeing; its notice is reproduced in inst/COPYRIGHTS.

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.6 by André Leite, 2 days 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: André Leite [aut, trl, cre] (ORCID: , Marcos Wasiliew [aut, trl] (ORCID: , Hugo Vasconcelos [aut, trl] (ORCID: , Carlos Amorim [aut, trl] (ORCID: , Diogo Bezerra [aut, trl] (ORCID: , Júlia Nascimento Barreto [aut, trl] (ORCID: , Geoff Boeing [aut, cph] (ORCID: , Author and copyright holder of 'OSMnx' , the 'Python' library that this package ports to R) , Srikanth Komala Sheshachala [ctb] (Issue reports and feature proposals (GitHub: talegari)) , StrategicProjects [cph, fnd] (Also copyright holder of the bundled Rust crate osmnxr-core) , 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