### Install OSMnx using Pip Source: https://osmnx.readthedocs.io/en/stable/installation.html Install OSMnx into a virtual environment using pip. Note that dependency compilation may be required if precompiled binaries are unavailable. ```bash pip install osmnx ``` -------------------------------- ### Install OSMnx with Pip Source: https://osmnx.readthedocs.io/en/stable/_sources/installation.rst.txt Install OSMnx using pip into a virtual environment. This method is simple if dependencies are already met, but may require manual compilation if precompiled binaries are unavailable. ```shell pip install osmnx ``` -------------------------------- ### osmnx.simplification._build_path Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Builds a path of nodes from a starting endpoint node to the next endpoint node, including interstitial nodes. ```APIDOC ## osmnx.simplification._build_path ### Description Build a path of nodes from one endpoint node to next endpoint node. ### Parameters * **G** (`MultiDiGraph`) – Input graph. * **endpoint** (`int`) – The endpoint node from which to start the path. * **endpoint_successor** (`int`) – The successor of endpoint through which the path to the next endpoint will be built. * **endpoints** (`set`[`int`]) – The set of all nodes in the graph that are endpoints. ### Returns * _path_ – The first and last items in the resulting path list are endpoint nodes, and all other items are interstitial nodes that can be removed subsequently. ### Return type list[int] ``` -------------------------------- ### Install OSMnx with Conda Source: https://osmnx.readthedocs.io/en/stable/_sources/installation.rst.txt Use this command to create a new conda environment named 'ox' and install OSMnx from the conda-forge channel. Add other desired packages after 'osmnx'. ```shell conda create --strict-channel-priority -c conda-forge -n ox osmnx ``` -------------------------------- ### Create Conda Environment for OSMnx Source: https://osmnx.readthedocs.io/en/stable/installation.html Use this command to create a new conda environment with OSMnx installed from conda-forge. Add other desired packages after 'osmnx'. ```bash conda create --strict-channel-priority -c conda-forge -n ox osmnx ``` -------------------------------- ### osmnx._nominatim._nominatim_request Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Send a HTTP GET request to the Nominatim API and return response. ```APIDOC ## osmnx._nominatim._nominatim_request ### Description Send a HTTP GET request to the Nominatim API and return response. ### Parameters #### Path Parameters None #### Query Parameters * **params** (OrderedDict[str, int | str]) - Required - Key-value pairs of parameters. * **request_type** (str) - Optional - Which Nominatim API endpoint to query, one of {“search”, “reverse”, “lookup”}. ### Returns * **response_json** (list[dict[str, Any]]) - The Nominatim API’s response. ``` -------------------------------- ### osmnx._http Module Usage Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html This snippet outlines the expected parameters for functions within the _http module, including url, response_json, and ok. It also highlights the recommendation to use OrderedDicts for parameters to ensure consistent URL hashing and cache hits. ```APIDOC ## osmnx._http module Users should always pass OrderedDicts instead of dicts of parameters into request functions, so the parameters remain in the same order each time, producing the same URL string, and thus the same hash. Otherwise you will get a cache miss when the URL’s parameters appeared in a different order. Parameters: * **url** (`str`) – The URL of the request. * **response_json** (`dict`[`str`, `Any`] | `list`[`dict`[`str`, `Any`]]) – The JSON HTTP response. * **ok** (`bool`) – A requests.response.ok value. Return type: `None` ``` -------------------------------- ### osmnx._overpass._make_overpass_settings Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Creates the settings string to be sent in an Overpass query. ```APIDOC ## _make_overpass_settings ### Description Make settings string to send in Overpass query. ### Returns - **overpass_settings** (str) - The settings.overpass_settings string formatted with “timeout” and “maxsize” values. ``` -------------------------------- ### self_loop_proportion Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Calculates the proportion of edges in a graph that are self-loops. A self-loop is an edge where the start and end nodes are the same. ```APIDOC ## self_loop_proportion(Gu) ### Description Calculate percent of edges that are self-loops in a graph. A self-loop is defined as an edge from node u to node v where u==v. ### Parameters #### Path Parameters - **Gu** (MultiGraph) - Undirected input graph. ### Returns - **proportion** (float) - Proportion of graph edges that are self-loops. ``` -------------------------------- ### osmnx.graph.graph_from_point Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Download and create a graph centered around a specific point. ```APIDOC ## osmnx.graph.graph_from_point ### Description Download and create a graph centered around a specific point. ### Parameters #### Path Parameters - **center_point** (tuple[float, float]) - Required - The (lat, lon) center point around which to construct the graph. Coordinates should be in unprojected latitude-longitude degrees (EPSG:4326). - **dist** (float) - Required - Retain only those nodes within this many meters of center_point, measuring distance according to dist_type. #### Query Parameters - **dist_type** (str) - Optional - {"bbox", "network"} If "bbox", retain only those nodes within a bounding box of dist length/width. If "network", retain only those nodes within dist network distance of the nearest node to center_point. - **network_type** (str) - Optional - {"all", "all_public", "bike", "drive", "drive_service", "walk"} What type of street network to retrieve if custom_filter is None. - **simplify** (bool) - Optional - If True, simplify graph topology with the simplify_graph function. - **retain_all** (bool) - Optional - If True, return the entire graph even if it is not connected. If False, retain only the largest weakly connected component. - **truncate_by_edge** (bool) - Optional - If True, retain nodes the outside bounding box if at least one of the node’s neighbors lies within the bounding box. - **custom_filter** (str | list[str] | None) - Optional - A custom ways filter to be used instead of the network_type presets, e.g. ‘[“power”~”line”]’ or ‘[“highway”~”motorway|trunk”]’. If str, the intersection of keys/values will be used, e.g., ‘[maxspeed=50][lanes=2]’ will return all ways having both maxspeed of 50 and two lanes. If list, the union of the list items will be used, e.g., [‘[maxspeed=50]’, ‘[lanes=2]’] will return all ways having either maximum speed of 50 or two lanes. Also pass in a network_type that is in settings.bidirectional_network_types if you want the graph to be fully bidirectional. ### Returns - **G** (networkx.MultiDiGraph) - The resulting MultiDiGraph. ### Notes Very large query areas use the utils_geo._consolidate_subdivide_geometry function to automatically make multiple requests: see that function’s documentation for caveats. ``` -------------------------------- ### osmnx.utils module Source: https://osmnx.readthedocs.io/en/stable/_sources/user-reference.rst.txt This section details the utility functions available in the osmnx.utils module. ```APIDOC ## osmnx.utils module This module contains general utility functions for OSMnx. ``` -------------------------------- ### _open_file Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Opens a file and returns a file object, optionally handling bz2 or gz files. It uses a wrapper context manager to ensure the file is always closed. ```APIDOC ## _open_file ### Description Open a file and return a file object, optionally handling bz2 or gz files. Uses a wrapper context manager to yield the file object to ensure the file will always get closed when the caller is finished with it. ### Parameters * **filepath** (`Path`) - Path to file. * **encoding** (`str`) - The file’s character encoding. ### Returns _file_ - The file handle. ### Return type _Iterator_[_TextIO_] ``` -------------------------------- ### find_nearest_nodes Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Finds the nearest network node(s) to given coordinate(s). This function is vectorized and can accept single coordinates or iterables of coordinates. It supports efficient nearest neighbor search using k-d trees for projected graphs and ball trees for unprojected graphs, provided optional dependencies are installed. ```APIDOC ## find_nearest_nodes ### Description Finds the nearest network node(s) to given coordinate(s). This function is vectorized and can accept single coordinates or iterables of coordinates. It supports efficient nearest neighbor search using k-d trees for projected graphs and ball trees for unprojected graphs, provided optional dependencies are installed. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **G** (nx.MultiDiGraph) – Graph in which to find nearest nodes. * **X** (float | Iterable[float]) – The points’ x (longitude) coordinates, in same CRS/units as graph and containing no nulls. * **Y** (float | Iterable[float]) – The points’ y (latitude) coordinates, in same CRS/units as graph and containing no nulls. * **return_dist** (bool) – If True, optionally also return the distance(s) between point(s) and nearest node(s). ### Returns _nn or (nn, dist)_ – Nearest node ID(s) or optionally a tuple of ID(s) and distance(s) between each point and its nearest node. ### Return Type int | npt.NDArray[np.int64] | tuple[int, float] | tuple[npt.NDArray[np.int64], npt.NDArray[np.float64]] ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### osmnx.settings module Source: https://osmnx.readthedocs.io/en/stable/_sources/user-reference.rst.txt This section details the functions and variables available in the osmnx.settings module, which are used for configuring OSMnx's behavior. ```APIDOC ## osmnx.settings module This module allows users to configure and manage OSMnx settings. ``` -------------------------------- ### k_shortest_paths Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Solves for the k shortest paths between an origin node and a destination node in a graph using Yen's algorithm. It yields each path as a list of node IDs. ```APIDOC ## k_shortest_paths ### Description Solve k shortest paths from an origin node to a destination node. Uses Yen’s algorithm. See also shortest_path to solve just the one shortest path. ### Parameters * **G** (`MultiDiGraph`) – Input graph. * **orig** (`int`) – Origin node ID. * **dest** (`int`) – Destination node ID. * **k** (`int`) – Number of shortest paths to solve. * **weight** (`str`) – Edge attribute to minimize when solving shortest paths. ### Yields * **path** – The node IDs constituting the next-shortest path. ### Return type `Iterator`[`list`[`int`]] ``` -------------------------------- ### osmnx.simplification._get_paths_to_simplify Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Generates all paths between endpoint nodes that need to be simplified. ```APIDOC ## osmnx.simplification._get_paths_to_simplify ### Description Generate all the paths to be simplified between endpoint nodes. The path is ordered from the first endpoint, through the interstitial nodes, to the second endpoint. ### Parameters * **G** (`MultiDiGraph`) – Input graph. * **node_attrs_include** (`Iterable`[`str`] | `None`) – Node attribute names for relaxing the strictness of endpoint determination. A node is always an endpoint if it possesses one or more of the attributes in node_attrs_include. * **edge_attrs_differ** (`Iterable`[`str`] | `None`) – Edge attribute names for relaxing the strictness of endpoint determination. A node is always an endpoint if its incident edges have different values than each other for any attribute in edge_attrs_differ. ### Yields * _path_to_simplify_ ### Return type `Iterator`[`list`[`int`]] ``` -------------------------------- ### osmnx.utils._get_logger Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Creates or returns an existing logger instance. ```APIDOC ## _get_logger ### Description Create a logger or return the current one if already instantiated. ### Parameters * **name** (`str`) – Name of the logger. * **filename** (`str`) – Name of the log file, without file extension. ### Returns * **logger** (`_Logger_`) – The logger. ``` -------------------------------- ### osmnx.graph.graph_from_polygon Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Download and create a graph within the boundaries of a (Multi)Polygon. ```APIDOC ## osmnx.graph.graph_from_polygon ### Description Download and create a graph within the boundaries of a (Multi)Polygon. This function uses filters to query the Overpass API: you can either specify a pre-defined network_type or provide your own custom_filter with Overpass QL. ### Parameters #### Path Parameters - **polygon** (Polygon | MultiPolygon) - Required - The geometry within which to construct the graph. Coordinates should be in unprojected latitude-longitude degrees (EPSG:4326). #### Query Parameters - **network_type** (str) - Optional - {"all", "all_public", "bike", "drive", "drive_service", "walk"} What type of street network to retrieve if custom_filter is None. - **simplify** (bool) - Optional - If True, simplify graph topology with the simplify_graph function. - **retain_all** (bool) - Optional - If True, return the entire graph even if it is not connected. If False, retain only the largest weakly connected component. - **truncate_by_edge** (bool) - Optional - If True, retain nodes outside polygon if at least one of the node’s neighbors lies within polygon. - **custom_filter** (str | list[str] | None) - Optional - A custom ways filter to be used instead of the network_type presets, e.g. ‘[“power”~”line”]’ or ‘[“highway”~”motorway|trunk”]’. If str, the intersection of keys/values will be used, e.g., ‘[maxspeed=50][lanes=2]’ will return all ways having both maxspeed of 50 and two lanes. If list, the union of the list items will be used, e.g., [‘[maxspeed=50]’, ‘[lanes=2]’] will return all ways having either maximum speed of 50 or two lanes. Also pass in a network_type that is in settings.bidirectional_network_types if you want the graph to be fully bidirectional. ### Returns - **G** (nx.MultiDiGraph) - The resulting MultiDiGraph. ### Notes Use the settings module’s useful_tags_node and useful_tags_way settings to configure which OSM node/way tags are added as graph node/edge attributes. If you want a fully bidirectional network, ensure your network_type is in settings.bidirectional_network_types before creating your graph. You can also use the settings module to retrieve a snapshot of historical OSM data as of a certain date, or to configure the Overpass server timeout, memory allocation, and other customizations. ``` -------------------------------- ### osmnx.io module Source: https://osmnx.readthedocs.io/en/stable/_sources/user-reference.rst.txt This section details the functions available in the osmnx.io module, which are used for input and output operations, such as saving and loading graph data. ```APIDOC ## osmnx.io module This module contains functions for reading from and writing to various file formats. ``` -------------------------------- ### osmnx.simplification module Source: https://osmnx.readthedocs.io/en/stable/_sources/user-reference.rst.txt This section details the functions available in the osmnx.simplification module, which are used for simplifying network geometries. ```APIDOC ## osmnx.simplification module This module contains functions for simplifying the geometry of network edges. ``` -------------------------------- ### osmnx.graph.graph_from_bbox Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Download and create a graph within a lat-lon bounding box. This function uses filters to query the Overpass API. ```APIDOC ## osmnx.graph.graph_from_bbox ### Description Download and create a graph within a lat-lon bounding box. This function uses filters to query the Overpass API: you can either specify a pre-defined network_type or provide your own custom_filter with Overpass QL. ### Parameters #### Path Parameters - **bbox** (tuple[float, float, float, float]) - Required - Bounding box as (left, bottom, right, top). Coordinates should be in unprojected latitude-longitude degrees (EPSG:4326). #### Query Parameters - **network_type** (str) - Optional - {"all", "all_public", "bike", "drive", "drive_service", "walk"} What type of street network to retrieve if custom_filter is None. - **simplify** (bool) - Optional - If True, simplify graph topology via the simplify_graph function. - **retain_all** (bool) - Optional - If True, return the entire graph even if it is not connected. If False, retain only the largest weakly connected component. - **truncate_by_edge** (bool) - Optional - If True, retain nodes the outside bounding box if at least one of the node’s neighbors lies within the bounding box. - **custom_filter** (str | list[str] | None) - Optional - A custom ways filter to be used instead of the network_type presets, e.g. ‘[“power”~”line”]’ or ‘[“highway”~”motorway|trunk”]’. If str, the intersection of keys/values will be used, e.g., ‘[maxspeed=50][lanes=2]’ will return all ways having both maxspeed of 50 and two lanes. If list, the union of the list items will be used, e.g., [‘[maxspeed=50]’, ‘[lanes=2]’] will return all ways having either maximum speed of 50 or two lanes. Also pass in a network_type that is in settings.bidirectional_network_types if you want the graph to be fully bidirectional. ### Returns - **G** (networkx.MultiDiGraph) - The resulting MultiDiGraph. ``` -------------------------------- ### osmnx._nominatim._download_nominatim_element Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Retrieve an OSM element from the Nominatim API. ```APIDOC ## osmnx._nominatim._download_nominatim_element ### Description Retrieve an OSM element from the Nominatim API. ### Parameters #### Path Parameters None #### Query Parameters * **query** (str | dict[str, str]) - Required - Query string or structured query dict. * **by_osmid** (bool) - Optional - If True, treat query as an OSM ID lookup rather than text search. * **limit** (int) - Optional - Max number of results to return. * **polygon_geojson** (bool) - Optional - Whether to retrieve the place’s geometry from the API. ### Returns * **response_json** (list[dict[str, Any]]) - The Nominatim API’s response. ``` -------------------------------- ### osmnx.io Parameters Source: https://osmnx.readthedocs.io/en/stable/user-reference.html The osmnx.io module provides parameters to customize the saving of graph data. These include options for Gephi compatibility and character encoding. ```APIDOC ## osmnx.io module This module contains parameters that affect how graph data is saved. ### Parameters * **gephi** (`bool`) – If True, give each edge a unique key/id for compatibility with Gephi’s interpretation of the GraphML specification. * **encoding** (`str`) – The character encoding of the saved GraphML file. ### Return Type `None` ``` -------------------------------- ### osmnx.graph.graph_from_bbox Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Downloads and creates a graph within a specified latitude-longitude bounding box. Users can choose from predefined network types or provide a custom filter for querying the Overpass API. Options include simplifying the graph, retaining all components, and truncating by edge. ```APIDOC ## osmnx.graph.graph_from_bbox ### Description Download and create a graph within a lat-lon bounding box. This function uses filters to query the Overpass API: you can either specify a pre-defined network_type or provide your own custom_filter with Overpass QL. Use the settings module’s useful_tags_node and useful_tags_way settings to configure which OSM node/way tags are added as graph node/edge attributes. If you want a fully bidirectional network, ensure your network_type is in settings.bidirectional_network_types before creating your graph. You can also use the settings module to retrieve a snapshot of historical OSM data as of a certain date, or to configure the Overpass server timeout, memory allocation, and other customizations. ### Parameters #### Path Parameters - **bbox** (tuple[float, float, float, float]) - Required - Bounding box as (left, bottom, right, top). Coordinates should be in unprojected latitude-longitude degrees (EPSG:4326). - **network_type** (str) - Optional - {"all", "all_public", "bike", "drive", "drive_service", "walk"} What type of street network to retrieve if custom_filter is None. - **simplify** (bool) - Optional - If True, simplify graph topology via the simplify_graph function. - **retain_all** (bool) - Optional - If True, return the entire graph even if it is not connected. If False, retain only the largest weakly connected component. - **truncate_by_edge** (bool) - Optional - If True, retain nodes the outside bounding box if at least one of the node’s neighbors lies within the bounding box. - **custom_filter** (str | list[str] | None) - Optional - A custom ways filter to be used instead of the network_type presets, e.g. ‘[“power”~”line”]’ or ‘[“highway”~”motorway|trunk”]’. If str, the intersection of keys/values will be used, e.g., ‘[maxspeed=50][lanes=2]’ will return all ways having both maxspeed of 50 and two lanes. If list, the union of the list items will be used, e.g., [‘[maxspeed=50]’, ‘[lanes=2]’] will return all ways having either maximum speed of 50 or two lanes. Also pass in a network_type that is in settings.bidirectional_network_types if you want the graph to be fully bidirectional. ### Returns - **_G_** (networkx.MultiDiGraph) - The resulting MultiDiGraph. ### Notes Very large query areas use the utils_geo._consolidate_subdivide_geometry function to automatically make multiple requests: see that function’s documentation for caveats. ``` -------------------------------- ### osmnx.convert module Source: https://osmnx.readthedocs.io/en/stable/_sources/user-reference.rst.txt This section details the functions available in the osmnx.convert module, which are used for converting between different data formats and structures. ```APIDOC ## osmnx.convert module This module contains functions for converting data between various formats. ``` -------------------------------- ### bbox_from_point Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Create a bounding box around a given latitude-longitude point with a specified distance in meters. Optionally projects the bounding box to UTM and returns the CRS. ```APIDOC ## bbox_from_point ### Description Create a bounding box around a (lat, lon) point. Create a bounding box some distance (in meters) in each direction (top, bottom, right, and left) from the center point and optionally project it. ### Parameters * **point** (`tuple`[`float`, `float`]) – The (lat, lon) center point to create the bounding box around. * **dist** (`float`) – Bounding box distance in meters from the center point. * **project_utm** (`bool`) – If True, return bounding box as UTM-projected coordinates. * **return_crs** (`bool`) – If True, and project_utm is True, then return the projected CRS too. ### Returns _bbox or bbox, crs_ – (left, bottom, right, top) or ((left, bottom, right, top), crs). ### Return type tuple[float, float, float, float] | tuple[tuple[float, float, float, float], _Any_] ``` -------------------------------- ### osmnx.utils.citation Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Prints the OSMnx package's citation information in various styles. ```APIDOC ## citation ### Description Print the OSMnx package’s citation information. Boeing, G. (2025). Modeling and Analyzing Urban Networks and Amenities with OSMnx. Geographical Analysis, 57(4), 567-577. doi:10.1111/gean.70009 ### Parameters * **style** (`str`) – {“apa”, “bibtex”, “ieee”} The citation format, either APA or BibTeX or IEEE. ### Returns * `None` ``` -------------------------------- ### overpass_settings Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Configuration for Overpass queries, including the query string format and dynamic value settings. ```APIDOC ## overpass_settings Settings string for Overpass queries. Default is "[out:json][timeout:{timeout}]{maxsize}". By default, the {timeout} and {maxsize} values are set dynamically by OSMnx when used. To query, for example, historical OSM data as of a certain date: ‘[out:json][timeout:90][date:"2019-10-28T19:20:00Z”]’. Use with caution. ``` -------------------------------- ### osmnx.graph.graph_from_place Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Download and create a graph within the boundaries of some place(s). This function uses filters to query the Overpass API, allowing for pre-defined network types or custom filters. ```APIDOC ## osmnx.graph.graph_from_place ### Description Download and create a graph within the boundaries of some place(s). The query must be geocodable and OSM must have polygon boundaries for the geocode result. This function uses filters to query the Overpass API: you can either specify a pre-defined network_type or provide your own custom_filter with Overpass QL. ### Parameters * **query** (`str` | `dict`[`str`, `str`] | `list`[`str` | `dict`[`str`, `str`]]) – The query or queries to geocode to retrieve place boundary polygon(s). * **network_type** (`str`) – {“all”, “all_public”, “bike”, “drive”, “drive_service”, “walk”} What type of street network to retrieve if custom_filter is None. * **simplify** (`bool`) – If True, simplify graph topology with the simplify_graph function. * **retain_all** (`bool`) – If True, return the entire graph even if it is not connected. If False, retain only the largest weakly connected component. * **truncate_by_edge** (`bool`) – If True, retain nodes outside the place boundary polygon(s) if at least one of the node’s neighbors lies within the polygon(s). * **which_result** (`int` | `None` | `list`[`int` | `None`]) – Which geocoding result to use. if None, auto-select the first (Multi)Polygon or raise an error if OSM doesn’t return one. * **custom_filter** (`str` | `list`[`str`] | `None`) – A custom ways filter to be used instead of the network_type presets, e.g. ‘[“power”~”line”]’ or ‘[“highway”~”motorway|trunk”]’. If str, the intersection of keys/values will be used, e.g., ‘[maxspeed=50][lanes=2]’ will return all ways having both maxspeed of 50 and two lanes. If list, the union of the list items will be used, e.g., [‘[maxspeed=50]’, ‘[lanes=2]’] will return all ways having either maximum speed of 50 or two lanes. Also pass in a network_type that is in settings.bidirectional_network_types if you want the graph to be fully bidirectional. ### Returns * _G_ – The resulting MultiDiGraph. ### Return type networkx.MultiDiGraph ### Notes Very large query areas use the utils_geo._consolidate_subdivide_geometry function to automatically make multiple requests: see that function’s documentation for caveats. ``` -------------------------------- ### osmnx.projection module Source: https://osmnx.readthedocs.io/en/stable/_sources/user-reference.rst.txt This section details the functions available in the osmnx.projection module, which are used for managing and transforming coordinate reference systems. ```APIDOC ## osmnx.projection module This module contains functions for handling coordinate reference system transformations. ``` -------------------------------- ### osmnx.routing.shortest_path Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Solves for the shortest path between origin(s) and destination(s) using Dijkstra’s algorithm. Can handle single or multiple origin/destination pairs and supports parallelization. ```APIDOC ## osmnx.routing.shortest_path ### Description Solve shortest path from origin node(s) to destination node(s) using Dijkstra’s algorithm. Can return a single path or a list of paths if multiple origins/destinations are provided. Supports parallelization with the `cpus` parameter. ### Method `shortest_path(G, orig, dest, *, weight='length', cpus=1)` ### Parameters #### Path Parameters * **G** (MultiDiGraph) - Input graph. * **orig** (int | Iterable[int]) - Origin node ID(s). * **dest** (int | Iterable[int]) - Destination node ID(s). * **weight** (str) - Edge attribute to minimize when solving shortest path. * **cpus** (int | None) - How many CPU cores to use if multiprocessing. If None, use all available. ### Returns * **path** (list[int] | None | list[list[int] | None]) - The node IDs constituting the shortest path, or a list of such paths if multiple origins/destinations are provided. Returns None for a path if it cannot be solved. ### Return Type list[int] | None | list[list[int] | None] ``` -------------------------------- ### osmnx.utils.citation Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Prints the OSMnx package's citation information in a specified format. ```APIDOC ## osmnx.utils.citation ### Description Print the OSMnx package’s citation information. Boeing, G. (2025). Modeling and Analyzing Urban Networks and Amenities with OSMnx. Geographical Analysis, 57(4), 567-577. doi:10.1111/gean.70009 ### Parameters * **style** (`str`) – {“apa”, “bibtex”, “ieee”} The citation format, either APA or BibTeX or IEEE. ### Returns * `None` ``` -------------------------------- ### osmnx._http._get_http_headers Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Updates default HTTP headers with OSMnx-specific information like user agent and referer. ```APIDOC ## osmnx._http._get_http_headers ### Description Update the default requests HTTP headers with OSMnx information. ### Parameters * **user_agent** (`str` | `None`) – The user agent. If None, use settings.http_user_agent value. * **referer** (`str` | `None`) – The referer. If None, use settings.http_referer value. * **accept_language** (`str` | `None`) – The accept language. If None, use settings.http_accept_language value. ### Returns * _headers_ – The updated HTTP headers. ### Return type dict[str, str] ``` -------------------------------- ### osmnx.bearing module Source: https://osmnx.readthedocs.io/en/stable/_sources/user-reference.rst.txt This section details the functions available in the osmnx.bearing module, which are related to calculating bearings between points. ```APIDOC ## osmnx.bearing module This module contains functions for calculating bearings between geographic points. ``` -------------------------------- ### osmnx.graph.graph_from_xml Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Creates a graph from data in an OSM XML file. It's important not to load an XML file previously generated by OSMnx, as this use case is not supported. Use the settings module’s useful_tags_node and useful_tags_way settings to configure which OSM node/way tags are added as graph node/edge attributes. ```APIDOC ## osmnx.graph.graph_from_xml ### Description Create a graph from data in an OSM XML file. Do not load an XML file previously generated by OSMnx: this use case is not supported and may not behave as expected. To save/load graphs to/from disk for later use in OSMnx, use the io.save_graphml and io.load_graphml functions instead. Use the settings module’s useful_tags_node and useful_tags_way settings to configure which OSM node/way tags are added as graph node/edge attributes. ### Parameters #### Path Parameters * **filepath** (str | Path) - Required - Path to file containing OSM XML data. * **bidirectional** (bool) - Optional - If True, create bidirectional edges for one-way streets. * **simplify** (bool) - Optional - If True, simplify graph topology with the simplify_graph function. * **retain_all** (bool) - Optional - If True, return the entire graph even if it is not connected. If False, retain only the largest weakly connected component. * **encoding** (str) - Optional - The OSM XML file’s character encoding. ### Returns * **G** (networkx.MultiDiGraph) - The resulting MultiDiGraph. ``` -------------------------------- ### osmnx._http._check_cache Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Checks if a key exists in the cache and returns its file path if found. ```APIDOC ## osmnx._http._check_cache ### Description Check if a key exists in the cache, and return its cache file path if so. ### Parameters * **key** (`str`) – The key to look for in the cache. ### Returns * _cache_filepath_ – Filepath to cached data for key if it exists, otherwise None. ### Return type _Path_ | None ``` -------------------------------- ### osmnx._http._config_dns Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Forces socket.getaddrinfo to use a consistent IP address for a given hostname, preventing issues with round-robin DNS. ```APIDOC ## osmnx._http._config_dns ### Description Force socket.getaddrinfo to use IP address instead of hostname. Resolves URL’s hostname to an IP address so that we use the same server for both checking the necessary pause duration and sending the query itself, even if there is round-robin redirecting among multiple server machines on the server-side. Mutates the getaddrinfo function so it uses the same IP address everytime it finds the hostname in the URL. ### Parameters * **url** (`str`) – The URL to consistently resolve the IP address of. ### Return type `None` ``` -------------------------------- ### osmnx.utils_geo module Source: https://osmnx.readthedocs.io/en/stable/_sources/user-reference.rst.txt This section details the geospatial utility functions available in the osmnx.utils_geo module. ```APIDOC ## osmnx.utils_geo module This module contains utility functions specifically for geospatial operations. ``` -------------------------------- ### osmnx.elevation module Source: https://osmnx.readthedocs.io/en/stable/_sources/user-reference.rst.txt This section details the functions available in the osmnx.elevation module, which are used for retrieving and working with elevation data. ```APIDOC ## osmnx.elevation module This module contains functions for accessing and processing elevation data. ``` -------------------------------- ### osmnx.features.features_from_place Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Download OSM features within the boundaries of some place(s). This function searches for features using tags and returns a GeoDataFrame. ```APIDOC ## features_from_place ### Description Download OSM features within the boundaries of some place(s). ### Parameters * **query** (str | dict[str, str] | list[str | dict[str, str]]) - The query or queries to geocode to retrieve place boundary polygon(s). * **tags** (dict[str, bool | str | list[str]]) - Tags for finding elements in the selected area. Results are the union, not intersection of the tags and each result matches at least one tag. * **which_result** (None) - Optional argument to specify which geocode result to use if multiple are returned. ### Returns * **gdf** (geopandas.GeoDataFrame) - The features, multi-indexed by element type and OSM ID. ``` -------------------------------- ### requests_kwargs Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Optional keyword arguments to pass to the requests package for configuring API connections. ```APIDOC ## requests_kwargs Optional keyword args to pass to the requests package when connecting to APIs, for example to configure authentication or provide a path to a local certificate file. More info on options such as auth, cert, verify, and proxies can be found in the requests package advanced docs. Default is {}. ``` -------------------------------- ### osmnx.stats module Source: https://osmnx.readthedocs.io/en/stable/_sources/user-reference.rst.txt This section details the functions available in the osmnx.stats module, which are used for calculating various statistics on street networks. ```APIDOC ## osmnx.stats module This module provides functions for calculating network statistics. ``` -------------------------------- ### osmnx.utils.ts Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Returns the current local timestamp as a formatted string. ```APIDOC ## osmnx.utils.ts ### Description Return current local timestamp as a string. ### Parameters * **style** (`str`) – {“datetime”, “iso8601”, “date”, “time”} Format the timestamp with this built-in style. * **template** (`str` | `None`) – If not None, format the timestamp with this format string instead of one of the built-in styles. ### Returns * **timestamp** (`str`) – The current timestamp. ``` -------------------------------- ### osmnx.graph.graph_from_address Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Download and create a graph within some distance of an address. This function uses filters to query the Overpass API: you can either specify a pre-defined network_type or provide your own custom_filter with Overpass QL. ```APIDOC ## graph_from_address(address, dist, *, dist_type='bbox', network_type='all', simplify=True, retain_all=False, truncate_by_edge=False, custom_filter=None) ### Description Download and create a graph within some distance of an address. This function uses filters to query the Overpass API: you can either specify a pre-defined network_type or provide your own custom_filter with Overpass QL. ### Parameters #### Path Parameters - **address** (str) - The address to geocode and use as the central point around which to construct the graph. - **dist** (float) - Retain only those nodes within this many meters of center_point, measuring distance according to dist_type. #### Query Parameters - **dist_type** (str) - {"network", "bbox"} If "bbox", retain only those nodes within a bounding box of dist. If "network", retain only those nodes within dist network distance from the centermost node. - **network_type** (str) - {"all", "all_public", "bike", "drive", "drive_service", "walk"} What type of street network to retrieve if custom_filter is None. - **simplify** (bool) - If True, simplify graph topology with the simplify_graph function. - **retain_all** (bool) - If True, return the entire graph even if it is not connected. If False, retain only the largest weakly connected component. - **truncate_by_edge** (bool) - If True, truncate graph edges that cross the boundary of the query area. - **custom_filter** (str) - If not None, use this custom Overpass QL filter to query the Overpass API. ``` -------------------------------- ### _single_shortest_path Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Solves the shortest path between an origin node and a destination node using Dijkstra's algorithm. This is a wrapper around networkx.shortest_path with added exception handling for unsolvable paths, returning None if a path cannot be found. ```APIDOC ## _single_shortest_path ### Description Solve the shortest path from an origin node to a destination node. This function uses Dijkstra’s algorithm. It is a convenience wrapper around networkx.shortest_path, with exception handling for unsolvable paths. If the path is unsolvable, it returns None. ### Parameters #### Path Parameters - **G** (MultiDiGraph) - Input graph. - **orig** (int) - Origin node ID. - **dest** (int) - Destination node ID. - **weight** (str) - Edge attribute to minimize when solving shortest path. ### Returns - **path** (list[int] | None) - The node IDs constituting the shortest path. ### Return type list[int] | None ``` -------------------------------- ### osmnx._http._resolve_cache_filepath Source: https://osmnx.readthedocs.io/en/stable/internals-reference.html Determines the cache file path for a given key using the configured cache folder and SHA-1 hashing. ```APIDOC ## osmnx._http._resolve_cache_filepath ### Description Determine a cache key’s corresponding cache file path. This uses the configured settings.cache_folder and calculates the 160 bit SHA-1 hash digest (40 hexadecimal characters) of key to determine a succinct but unique cache filename. ### Parameters * **key** (`str`) – The key for which to generate a cache file path, for example, a URL. * **extension** (`str`) – The desired cache file’s extension. ### Returns * _cache_filepath_ – Cache file path corresponding to key. ### Return type _Path_ ``` -------------------------------- ### osmnx.features.features_from_bbox Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Download OSM features within a lat-lon bounding box. This function searches for features using tags and returns a GeoDataFrame. ```APIDOC ## features_from_bbox ### Description Download OSM features within a lat-lon bounding box. ### Parameters * **bbox** (tuple[float, float, float, float]) - Bounding box as (left, bottom, right, top). Coordinates should be in unprojected latitude-longitude degrees (EPSG:4326). * **tags** (dict[str, bool | str | list[str]]) - Tags for finding elements in the selected area. Results are the union, not intersection of the tags and each result matches at least one tag. ### Returns * **gdf** (geopandas.GeoDataFrame) - The features, multi-indexed by element type and OSM ID. ``` -------------------------------- ### osmnx.io.save_graph_xml Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Save graph to disk as an OSM XML file. This function exists only to allow serialization to the OSM XML format for applications that require it, and has constraints to conform to that. As such, it has a limited use case which does not include saving/loading graphs for subsequent OSMnx analysis. ```APIDOC ## osmnx.io.save_graph_xml ### Description Save graph to disk as an OSM XML file. This function exists only to allow serialization to the OSM XML format for applications that require it, and has constraints to conform to that. As such, it has a limited use case which does not include saving/loading graphs for subsequent OSMnx analysis. ### Parameters #### Path Parameters - **G** (MultiDiGraph) - Unsimplified, unprojected graph to save as an OSM XML file. - **filepath** (str | Path | None) - Path to the saved file including extension. If None, use default settings.data_folder/graph.osm. - **way_tag_aggs** (dict[str, Any] | None) - Keys are OSM way tag keys and values are aggregation functions (anything accepted as an argument by pandas.agg). Allows user to aggregate graph edge attribute values into single OSM way values. If None, or if some tag’s key does not exist in the dict, the way attribute will be assigned the value of the first edge of the way. - **encoding** (str) - The character encoding of the saved OSM XML file. ### Returns - **None** ``` -------------------------------- ### shortest_path Source: https://osmnx.readthedocs.io/en/stable/user-reference.html Solves for the shortest path between origin and destination node(s) using Dijkstra’s algorithm. It can handle single or multiple origin-destination pairs and supports parallel computation. ```APIDOC ## shortest_path ### Description Solve shortest path from origin node(s) to destination node(s). Uses Dijkstra’s algorithm. If orig and dest are single node IDs, this will return a list of the nodes constituting the shortest path between them. If orig and dest are lists of node IDs, this will return a list of lists of the nodes constituting the shortest path between each origin-destination pair. If a path cannot be solved, this will return None for that path. You can parallelize solving multiple paths with the cpus parameter, but be careful to not exceed your available RAM. See also k_shortest_paths to solve multiple shortest paths between a single origin and destination. For additional functionality or different solver algorithms, use NetworkX directly. ### Parameters * **G** (`MultiDiGraph`) – Input graph. * **orig** (`int` | `list`[`int`]) – Origin node ID or list of origin node IDs. * **dest** (`int` | `list`[`int`]) – Destination node ID or list of destination node IDs. * **weight** (`str`) – Edge attribute to minimize when solving shortest paths. * **cpus** (`int`) – Number of CPUs to use for parallel processing. Defaults to 1. ### Returns * A list of nodes constituting the shortest path, or a list of lists if multiple origin-destination pairs are provided. Returns None for unsolvable paths. ### Return type `list`[`int`] | `list`[`list`[`int`]] | `None` ```