An R port of 'OSMnx', the 'Python' library by Geoff Boeing
(Boeing, 2025,
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.
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")
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))
osmnxr is split into a tidy R API over a Rust compute core:
The pipeline, from a place name to an analyzable network:
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.
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.
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.
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).
MIT © André Leite and contributors / StrategicProjects. OSMnx, which this
package ports, is MIT © 2016–2026 Geoff Boeing; its notice is reproduced in
inst/COPYRIGHTS.