{"id":5356,"library":"osmnx","title":"OSMnx","description":"OSMnx is a Python package that simplifies the process of downloading, modeling, analyzing, and visualizing street networks and other geospatial features directly from OpenStreetMap. It is built upon NetworkX and GeoPandas, providing a powerful toolkit for urban and spatial analysis. The current version is 2.1.0, and the library maintains an active development cycle with regular updates and major releases that may introduce breaking changes.","status":"active","version":"2.1.0","language":"en","source_language":"en","source_url":"https://github.com/gboeing/osmnx","tags":["geospatial","mapping","openstreetmap","networks","urban planning","visualization","graph theory"],"install":[{"cmd":"pip install osmnx","lang":"bash","label":"PyPI (recommended if dependencies are pre-installed)"},{"cmd":"conda install -c conda-forge osmnx","lang":"bash","label":"Conda (recommended for easier dependency management)"}],"dependencies":[{"reason":"Core geospatial data structures and operations.","package":"geopandas"},{"reason":"Core graph data structures and algorithms.","package":"networkx"},{"reason":"Numerical computing.","package":"numpy"},{"reason":"Data manipulation and analysis.","package":"pandas"},{"reason":"HTTP requests to OpenStreetMap APIs.","package":"requests"},{"reason":"Geometric object manipulation.","package":"shapely"},{"reason":"For plotting and visualization.","package":"matplotlib","optional":true},{"reason":"For handling raster data, e.g., elevation models.","package":"rasterio","optional":true},{"reason":"For spatial indexing and machine learning algorithms, e.g., nearest neighbors.","package":"scikit-learn","optional":true},{"reason":"For scientific computing, used in some analysis functions.","package":"scipy","optional":true}],"imports":[{"note":"Standard convention for importing the library.","symbol":"osmnx","correct":"import osmnx as ox"},{"note":"Accessing specific modules like 'graph' directly is common, but often 'ox.graph' is sufficient.","symbol":"graph","correct":"import osmnx.graph as ox_graph"},{"note":"Accessing specific modules like 'plot' directly is common, but often 'ox.plot' is sufficient.","symbol":"plot","correct":"import osmnx.plot as ox_plot"}],"quickstart":{"code":"import osmnx as ox\n\n# Configure osmnx to use a cache for API calls\nox.settings.use_cache = True\n\n# Download and model a street network for a place\nplace = \"Piedmont, California, USA\"\nG = ox.graph.graph_from_place(place, network_type=\"drive\")\n\n# Plot the graph\nfig, ax = ox.plot_graph(G)","lang":"python","description":"This quickstart demonstrates how to download a drivable street network for a specified place and then visualize it. It also shows how to enable caching for API requests."},"warnings":[{"fix":"Consult the official OSMnx 2.0 Migration Guide and the Examples Gallery. When running v1.9.x, pay attention to `FutureWarning` messages, which provide guidance for v2.0 compatibility. Many function signatures and module locations have changed.","message":"The OSMnx 2.0 release (November 2024) introduced significant breaking changes, including a streamlined API, refactored modules, and the removal of previously deprecated functionality. Code written for v1.x will likely require updates to be compatible with v2.x.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"The recommended installation method, especially for users encountering issues, is to use `conda` via the `conda-forge` channel (`conda install -c conda-forge osmnx`). Conda handles the complex binary dependencies more reliably.","message":"Installing OSMnx via `pip` can be challenging on some systems due to its dependencies (e.g., GeoPandas, Shapely, Rasterio) which rely on compiled C/C++ libraries. Compilation issues can arise.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Familiarize yourself with the core concepts and data structures of NetworkX and GeoPandas. The OSMnx documentation and examples often assume a basic understanding of these libraries.","message":"OSMnx heavily leverages NetworkX graphs and GeoPandas GeoDataFrames. Users unfamiliar with these underlying libraries may struggle to effectively use or troubleshoot OSMnx, as its data models are built upon them.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always include a clear attribution to OpenStreetMap when presenting or publishing data or visualizations derived from OSMnx. Refer to OpenStreetMap's copyright and license guidelines for specifics.","message":"As OSMnx retrieves data from OpenStreetMap, all derivative works and visualizations generated using OSMnx must provide proper attribution to OpenStreetMap, in accordance with its open data license.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `.iloc` for explicit positional indexing (e.g., `x.iloc[0]`, `x.iloc[1]`) to access elements from a `pandas.Series` within `apply` functions, ensuring future compatibility and suppressing warnings.","message":"In recent pandas versions, directly accessing elements of a `pandas.Series` by positional index (e.g., `x[0]`, `x[1]`) within `.apply()` functions for geographic coordinates (latitude/longitude) is deprecated and will raise a `FutureWarning`. This is common in functions like `ox.distance.nearest_nodes`.","severity":"deprecated","affected_versions":"Pandas >= 2.0 (and OSMnx usage with it)"},{"fix":"Enable and configure OSMnx's caching (`ox.settings.use_cache = True`) to minimize redundant API calls. Design your queries to be as specific and small as possible, and introduce delays between large requests if necessary to avoid overwhelming the API.","message":"OSMnx uses the OpenStreetMap Overpass API for data retrieval. Frequent or very large data requests can lead to hitting API rate limits, which may result in failed queries or temporary IP blocks from the Overpass server.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For performance-critical analyses on massive graphs, consider exporting the OSMnx graph to formats compatible with faster graph libraries like `igraph` or `graph-tool` (which have C backends) for specific computational tasks, then re-importing results if needed.","message":"For very large graphs, some network analysis functions provided by NetworkX (and consequently used by OSMnx) can be computationally intensive and slow, as NetworkX is primarily a Python-native library.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}