Geo routing for Python users
Project description
Geo routing for Python users, supporting most of the routing tools, including OSRM, Google Maps, Bing Maps, etc. with a unified API.
Warning!!! This project is under active development, wait for the release of version 1.0.0 if you want to use it in production. This package is inspired by geopy. Please help to improve this package by submitting issues and pull requests.
- Free software: MIT license
- Documentation: https://wybert.github.io/georouting
Features
- Support most of the routing services, including Google Maps, Bing Maps, OSRM, etc.
- Provide a unified API for routing services
- Support calculating the travel distance matrix between multiple origins and destinations
- Support calculating the travel distance according to OD pairs.
- Easy to visualize the routing results
- Return the travel distance matrix in a Pandas
Dataframe
you like - Return the routing results in a Geopandas
GeoDataFrame
- Easy to extend to support more routing services
Installation
Using pip
To install georouting, run this command in your terminal:
pip install georouting
or install from GitHub source
pip install git+https://github.com/wybert/georouting.git
If you don't have pip installed, this Python installation guide can guide you through the process.
Using conda
This is not yet available on conda-forge,
conda install -c conda-forge georouting
or use mamba
mamba install -c conda-forge georouting
Install from sources
The sources for georouting can be downloaded from the Github repo.
You can clone the public repository:
git clone git://github.com/wybert/georouting
Then install it with:
python setup.py install
Usage
# how to get routing distance matrix from OSRMRouter
import pandas as pd
data = pd.read_csv("https://raw.githubusercontent.com/wybert/georouting/main/docs/data/sample_3.csv",index_col=0)
one_od_pair = data.iloc[2]
data.head()
from georouting.routers import GoogleRouter
# create a router object with the google_key
router = GoogleRouter(google_key,mode="driving")
# get the route between the origin and destination, this will return a Route object
# this will call the Google Maps API
route = router.get_route([one_od_pair["ZIP_lat"],one_od_pair["ZIP_lon"]],
[one_od_pair["AHA_ID_lat"],one_od_pair["AHA_ID_lon"]])
# Now you can get the distance and duration of the route in meters and seconds
print("Distance: {} meters".format(route.get_distance()))
print("Duration: {} seconds".format(route.get_duration()))
df= route.get_route_geopandas()
df.head()
df.explore(column="speed (m/s)",style_kwds={"weight":11,"opacity":0.8})
TODO
- Google Maps
- Bing Maps
- OSRM Routing
- add more documentation for google router
- add more documentation for bing router
- add more documentation for osrm router
- built and host documentation
- Fix the update in Pypi
- add get_route_distance_batch API
- add visualization for the route, better with o and d markers
- Limit the number of origins and destinations in the distance matrix
- avoid repeat documentation
- add ESRI router
- Add test
- Add more examples
- Add how to contribute
- change the show case use OSRM
- add OSMnx router
- static plot for the route
- add one API for all routers
- Add how to cite
Credits
This package was created with Cookiecutter and the giswqs/pypackage project template.
Project details
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
File details
Details for the file georouting-0.0.8.tar.gz
.
File metadata
- Download URL: georouting-0.0.8.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6807dcfa55a1667ed360225d2bffd137f91e8fb5ed29f4b8c9e7e5389d7cb4f |
|
MD5 | f1468d9fd6837eaa908571322a3e5e94 |
|
BLAKE2b-256 | d668befd0e12eba322291c6bfeb530f641f945d51334cc608286d8eb610571cc |
File details
Details for the file georouting-0.0.8-py2.py3-none-any.whl
.
File metadata
- Download URL: georouting-0.0.8-py2.py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0abf4122bfe61dc71a7166b1f2ba1513c9dd7e824278a355e21caf1bc4e2c05 |
|
MD5 | 2e09218bc538826690da78580ab54dd1 |
|
BLAKE2b-256 | 9badb1cf36245cfca3b4b4d2e01bee739fcf93adf3e174b21c140b328b7ae63b |