OSMnx Documentation
repository·main·Indexed 26 days ago
https://github.com/gboeing/osmnxOSMnx is a Python library for downloading, modeling, analyzing, and visualizing street networks and other geospatial features from OpenStreetMap. It allows users to model walking, driving, or biking networks as NetworkX MultiDiGraphs and perform analysis on urban amenities, building footprints, transit stops, elevation data, and routing. The library includes modules for geocoding, graph simplification, coordinate projection, and statistical analysis of urban networks.
What's inside OSMnx
- OSMnx is a Python package designed to download, model, analyze, and visualize street networks and other geospatial features from OpenStreetMap. It allows users to model walking, driving, or biking networks with minimal code and perform analysis on urban amenities, building footprints, transit stops, elevation data, street orientations, speed/travel time, and routing.
Install OSMnx using Pip or uv
mainYou can install OSMnx into a virtual environment using
piporuv. Note that while OSMnx is pure Python, it depends on packages that require compiled C/C++ libraries. If your system lacks precompiled binaries for these dependencies, you may encounter installation challenges. If you encounter issues withpip, use the Conda installation method instead.pip install osmnxInstall OSMnx using Conda or Mamba
mainThe recommended and most reliable way to install OSMnx is via
condaormambausing theconda-forgechannel. This method handles complex C/C++ dependencies automatically. To include additional packages likejupyterlabin the same environment, append them to the command.To upgrade OSMnx, it is recommended to remove the existing environment and recreate it using the command below.
conda create --strict-channel-priority -c conda-forge -n ox osmnxGet started with OSMnx
mainTo begin using OSMnx, follow these four steps:
- Install OSMnx: Follow the official installation guide.
- Understand the core concepts: Read the 'Introducing OSMnx' section in the documentation.
- Learn via examples: Work through the OSMnx
Examples Galleryfor step-by-step tutorials and sample code. - Reference the API: Consult the
user-referencefor complete technical details on using the package.
Note on dependencies: OSMnx relies heavily on
NetworkXandGeoPandasdata structures. It is highly recommended to familiarize yourself with their respective user guides to effectively work with OSMnx outputs.Install OSMnx
mainTo install OSMnx, follow the official installation guide at https://osmnx.readthedocs.io/en/stable/installation.html.Learn OSMnx via Getting Started and Examples
mainFor a comprehensive introduction and FAQ, refer to the Getting Started guide. For step-by-step tutorials and sample code, explore the Examples Gallery.Run OSMnx with Docker
mainYou can run OSMnx along with JupyterLab directly using the official OSMnx Docker image available on Docker Hub.Explore OSMnx usage examples and reference documentation
mainTo learn how to use OSMnx, you can consult the following resources:
- Examples Gallery: For step-by-step demonstrations of OSMnx functionality, visit the OSMnx Examples Gallery.
- User Reference: For detailed technical documentation on specific functions and API usage, consult the user-reference (internal link).
- Projects: To see real-world applications of the library, view recent projects that utilize OSMnx.
- StackOverflow: For specific usage questions, search or ask on StackOverflow.
Configure OSMnx settings
mainUse thesettingsmodule to adjust global OSMnx behavior. This includes configuring logging, caching, server endpoints, and retrieving historical snapshots of OpenStreetMap data by specifying a date. Detailed configuration options are available in thesettingsmodule documentation.Get support for OSMnx
mainIf you encounter issues:
- For technical reference: Consult the User Reference.
- For 'how-to' or usage questions: Ask on StackOverflow.
- For bug tracking or feature development: Use the GitHub issue tracker.
Adhere to API usage limits
mainOSMnx uses the Overpass and Nominatim APIs, which have rate limits. To avoid being blocked:
- Do not run multiple/parallel OSMnx instances simultaneously to circumvent limits.
- If you need to perform high-volume queries (e.g., >1,000/day), you should host your own local Overpass instance and configure OSMnx to use it.
Model street networks as MultiDiGraphs
mainUse the
graphmodule to retrieve spatial network data (streets, paths, rail, canals, etc.) from the Overpass API. OSMnx models these as NetworkXMultiDiGraphs(nonplanar directed graphs).Key behaviors:
- Directionality: One-way streets are single directed edges; bidirectional streets are represented by two reciprocal directed edges.
- Topology: The model correctly handles interchanges, bridges, and tunnels by treating edge crossings as non-intersections unless a true junction exists.
- Querying: You can query by lat-lon point, address, bounding box, bounding polygon, or place name. You can use built-in network types or custom
Overpass QLfilters.