No project description provided
Project description
OsmRx
A geographic Python library to extract Open Street Map roads (and POIs) from a location or a bounding box, in order to create a graph thanks to Rustworkx. OsmRx is able to clean a network based on Linestring geometries and connect Point geometries. The graph built is able to process graph-analysis (shortest-path, isochrones...)
Capabilities:
- load data from a location name or a bounding box (roads and pois)
- graph creation (and topology processing and cleaning)
- shortest path
- isochrone builder
Check the demo here
How to install it ?
with pip
pip install osmrx
How to use it ?
Check the jupyter notebook here
Check the wiki: TODO
Get POIs
Find the Points of interest from a location (Point(s)) or a bounding box:
- OSM attributes are returned
- features ready to be used with shapely, GeoPandas (...):
from osmrx.main.pois import Pois
location_name = "lyon"
# Initialize the Pois class
pois_object = Pois()
# call .from_location(location: str) or .from_bbox(bounds: Tuple[float, float, float, float]) to get data from your location
pois_object.from_location(location_name) # nominatim api is used to get Lyon coordinates
# It returns a list of dictionnaries [{"geometry": Point(...), "attribute": "...", ...}
# Free for you to use it with GeoPandas or something else (epsg=4326)
pois_data_found = pois_object.data
Get Roads
Find the vehicle or pedestrian network (LineString(s)) from a location or a bounding box:
- OSM attributes available
- OSM features ready to be used with shapely, GeoPandas (...):
- data cleaned regarding classical topology rules
from osmrx.main.roads import Roads
# Choose the vehicle or the pedestrian network
roads_object = Roads("vehicle")
# from_location(location: str) is available
roads_object.from_bbox({6.019674, 4.023742, 46.072575, 4.122018})
# It returns a list of dictionnaries [{"geometry": Point(...), "attribute": "...", ...}
# Free for you to use it with GeoPandas or something else (epsg=4326)
roads_data_found = roads_object.data
# return the rustworkx graph (directed for vehicle / undirected for pedestrian)
graph = roads_object.graph
# Free for you to compute graph analysis
Compute a shortest path
Compute the shortest path from an ordered list of Point(s) (at least 2)
from shapely import Point
from osmrx.main.roads import GraphAnalysis
# use the GraphAnalysis class and set:
# the network type (pedestrian or vehicle) and an ordered list of 2 Shapely Points defining the source and the target
# of your shortest path)
analysis_object = GraphAnalysis("pedestrian",
[Point(4.0793058, 46.0350304), Point(4.0725246, 46.0397676)]) # (epsg=4326)
paths_built = analysis_object.get_shortest_path()
for path_object in paths_built:
print(path_object.path) # LineString shortest path (epsg=4326)
print(path_object.features()) # List of LineString (with osm attributes) composing the path found
Compute an Isochrone
Build an isochrone (Polygon(s)) from a Point
from shapely import Point
from osmrx.main.roads import GraphAnalysis
# use the GraphAnalysis class and set:
# the network type (pedestrian or vehicle) and a list of one Shapely Point (epsg=4326) to build the isochone
analysis_object = GraphAnalysis("vehicle", [Point(4.0793058, 46.0350304)])
# Set the distance intervals to compute the isochone with a list of integer or float
isochrones_built = analysis_object.isochrones_from_distance([0, 250, 500, 1000, 1500])
# List of Polygons with a distance attributes based on the intervals defined
print(isochrones_built.data)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file osmrx-0.3.0.tar.gz.
File metadata
- Download URL: osmrx-0.3.0.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0 CPython/3.13.1 Linux/6.8.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ca1b0d1c7213491340f6a813d49d63f87c535c9aad9443340b699249fa4206e
|
|
| MD5 |
1d9c9c0245d777aec7bc56aa248f47a2
|
|
| BLAKE2b-256 |
4e852c4f4da6d3eef2e09a539c4c3497704778c2628b9cb049c790afbec91892
|
File details
Details for the file osmrx-0.3.0-py3-none-any.whl.
File metadata
- Download URL: osmrx-0.3.0-py3-none-any.whl
- Upload date:
- Size: 36.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0 CPython/3.13.1 Linux/6.8.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37b9e3939d61b619a243a7139b99a74426bcabc28d90f1fedfee896e26c7a755
|
|
| MD5 |
51ef7f04db1b2327059df5228ee6e04a
|
|
| BLAKE2b-256 |
75a80b1d64ee55db5fe045afed0cff902a21d462d0dbe634a0a1be17871328ce
|