OSMnx Documentation

repository·main·Indexed 26 days ago

https://github.com/gboeing/osmnx

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

Tokens
11.9K
Snippets
6
Records
107
Agent score
91%

What's inside OSMnx

  1. Overview of OSMnx

    main
    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.
  2. Install OSMnx using Pip or uv

    main

    You can install OSMnx into a virtual environment using pip or uv. 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 with pip, use the Conda installation method instead.

    pip install osmnx
  3. Install OSMnx using Conda or Mamba

    main

    The recommended and most reliable way to install OSMnx is via conda or mamba using the conda-forge channel. This method handles complex C/C++ dependencies automatically. To include additional packages like jupyterlab in 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 osmnx
  4. Get started with OSMnx

    main

    To begin using OSMnx, follow these four steps:

    1. Install OSMnx: Follow the official installation guide.
    2. Understand the core concepts: Read the 'Introducing OSMnx' section in the documentation.
    3. Learn via examples: Work through the OSMnx Examples Gallery for step-by-step tutorials and sample code.
    4. Reference the API: Consult the user-reference for complete technical details on using the package.

    Note on dependencies: OSMnx relies heavily on NetworkX and GeoPandas data structures. It is highly recommended to familiarize yourself with their respective user guides to effectively work with OSMnx outputs.

  5. Explore OSMnx usage examples and reference documentation

    main

    To 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.
  6. Configure OSMnx settings

    main
    Use the settings module 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 the settings module documentation.
  7. Adhere to API usage limits

    main

    OSMnx 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.
  8. Model street networks as MultiDiGraphs

    main

    Use the graph module to retrieve spatial network data (streets, paths, rail, canals, etc.) from the Overpass API. OSMnx models these as NetworkX MultiDiGraphs (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 QL filters.