{"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":"python","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,"search_vec":"'2.1.0':46 'activ':52 'analysi':41 'analyz':14 'break':64 'built':28 'chang':65 'current':43 'cycl':54 'develop':53 'direct':23 'download':12 'featur':22 'geopanda':32 'geospati':21,66 'graph':73 'introduc':63 'librari':49 'maintain':50 'major':59 'map':67 'may':62 'model':13 'network':18,69 'networkx':30 'openstreetmap':25,68 'osmnx':1,2 'packag':6 'plan':71 'power':35 'process':10 'provid':33 'python':5 'regular':56 'releas':60 'simplifi':8 'spatial':40 'street':17 'theori':74 'toolkit':36 'updat':57 'upon':29 'urban':38,70 'version':44 'visual':16,72","created_at":"2026-04-14T01:30:19.554691+00:00","updated_at":"2026-04-16T17:49:51.184644+00:00","problems":[{"fix":"Install osmnx using pip or, preferably, conda due to its complex geospatial dependencies: `conda install -c conda-forge osmnx` or `pip install osmnx`.","cause":"The `osmnx` package is not installed in the current Python environment, or the environment where it is installed is not active.","error":"ModuleNotFoundError: No module named 'osmnx'"},{"fix":"Update OSMnx to the latest version and adjust the call to `ox.projection.project_gdf()`: `gdf = ox.projection.project_gdf(gdf)`.","cause":"This error typically occurs when using an older version of OSMnx where the `project_gdf` function was directly in the main `osmnx` namespace. In newer versions (0.14.0 and above), it was moved to `osmnx.projection.project_gdf`.","error":"AttributeError: module 'osmnx' has no attribute 'project_gdf'"},{"fix":"For Debian/Ubuntu, install `libspatialindex-dev`: `sudo apt install libspatialindex-dev`. For macOS, use Homebrew: `brew install spatialindex`. For other systems, consult the `rtree` installation documentation or use `conda` to install OSMnx, as it typically handles these dependencies: `conda install -c conda-forge osmnx`.","cause":"This error occurs during OSMnx installation or import, specifically when the `rtree` dependency cannot find the `libspatialindex_c` shared library, which is a system-level geospatial dependency. This is common on Linux and when using pip for installation.","error":"OSError: Could not find libspatialindex_c library file"},{"fix":"Recreate your environment and install compatible versions. Ensure OSMnx >= 1.3 for Shapely >= 2.0. The recommended approach is to install OSMnx via conda, which manages compatible dependency versions: `conda create -n ox --strict-channel-priority -c conda-forge osmnx`.","cause":"This issue arises from an incompatibility between the installed versions of OSMnx and its dependency, Shapely. Specifically, older OSMnx versions (prior to 1.3) are not compatible with Shapely 2.0 or newer.","error":"ImportError: cannot import name 'TopologicalError' from 'shapely.geos'"},{"fix":"Verify the spelling and specificity of the place name. Try varying the query string, providing a structured query dictionary, or specifying a `which_result` parameter to select a different geocoding result. If a polygon boundary is missing, consider using `osmnx.graph_from_address()` with a `dist` parameter instead.","cause":"This error from NetworkX (a core dependency of OSMnx) indicates that the `osmnx.graph_from_place()` function (or similar) was unable to find or download any nodes or edges for the specified geographic query, resulting in an empty or 'null' graph. This can happen if the place name is misspelled, ambiguous, or if OpenStreetMap does not have detailed data for that specific location or geometry type.","error":"NetworkXPointlessConcept: Connectivity is undefined for the null graph"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.1.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/gboeing/osmnx","docs":"https://osmnx.readthedocs.io","changelog":null,"pypi":"https://pypi.org/project/osmnx/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","web-framework","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}