All Projects → gis-ops → routing-py

gis-ops / routing-py

Licence: Apache-2.0 license
🌎 Python library to access all public routing, isochrones and matrix APIs in a consistent manner.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to routing-py

Osrm Backend
Open Source Routing Machine - C++ backend
Stars: ✭ 4,716 (+4349.06%)
Mutual labels:  osrm, routing, isochrones
osrm-backend-k8s
Open Source Routing Machine (OSRM) osrm-backend for Kubernetes on Google Container Engine (GKE).
Stars: ✭ 34 (-67.92%)
Mutual labels:  osrm, osrm-backend
spopt
Spatial Optimization
Stars: ✭ 186 (+75.47%)
Mutual labels:  routing, spatial-analysis
graphhopper-ios
iOS Port of the GraphHopper road routing engine
Stars: ✭ 67 (-36.79%)
Mutual labels:  navigation, graphhopper
Mapbox Directions Swift
Traffic-aware directions and map matching in Swift on iOS, macOS, tvOS, watchOS, and Linux
Stars: ✭ 115 (+8.49%)
Mutual labels:  navigation, routing
Url Parser
Parse URLs into nicely structured data
Stars: ✭ 118 (+11.32%)
Mutual labels:  navigation, routing
easyRNRoute
https://medium.com/@kevinle/comprehensive-routing-and-navigation-in-react-native-made-easy-6383e6cdc293#.nttfeeq3p
Stars: ✭ 25 (-76.42%)
Mutual labels:  navigation, routing
Nested Navigation Demo Flutter
Nested navigation with BottomNavigationBar
Stars: ✭ 367 (+246.23%)
Mutual labels:  navigation, routing
organicmaps
🍃 Organic Maps is a free Android & iOS offline maps app for travelers, tourists, hikers, and cyclists. It uses crowd-sourced OpenStreetMap data and is developed with love by MapsWithMe (MapsMe) founders and our community. No ads, no tracking, no data collection, no crapware. Your donations and positive reviews motivate and inspire our small team!
Stars: ✭ 3,689 (+3380.19%)
Mutual labels:  navigation, routing
public-transit-tools
Tools for working with GTFS public transit data in ArcGIS
Stars: ✭ 126 (+18.87%)
Mutual labels:  spatial-analysis, isochrones
HerePy
A library that provides a Python interface to the HERE APIs.
Stars: ✭ 73 (-31.13%)
Mutual labels:  routing, heremaps
Corenavigation
📱📲 Navigate between view controllers with ease. 💫 🔜 More stable version (written in Swift 5) coming soon.
Stars: ✭ 69 (-34.91%)
Mutual labels:  navigation, routing
Findme
An ARKit App that can help your friends to find you
Stars: ✭ 483 (+355.66%)
Mutual labels:  navigation, routing
Swiftuirouter
Routing in SwiftUI
Stars: ✭ 242 (+128.3%)
Mutual labels:  navigation, routing
Router
🛣 Simple Navigation for iOS
Stars: ✭ 438 (+313.21%)
Mutual labels:  navigation, routing
open route service
An encapsulation made around openrouteservice API for Dart and Flutter projects. Made for easy generation of Routes and Directions on Maps, Isochrones, Time-Distance Matrix, Pelias Geocoding, POIs, Elevation and routing Optimizations using their amazing API.
Stars: ✭ 20 (-81.13%)
Mutual labels:  isochrones, openrouteservice
node-isochrone
NodeJS isochrone map library
Stars: ✭ 27 (-74.53%)
Mutual labels:  osrm, isochrones
ASMapLauncher
ASMapLauncher is a library for iOS written in Swift that helps navigation with various mapping applications.
Stars: ✭ 41 (-61.32%)
Mutual labels:  navigation, routing
Mapbox Java
The Mapbox Java SDK – Java wrappers around Mapbox APIs and other location data
Stars: ✭ 309 (+191.51%)
Mutual labels:  navigation, mapbox
Router-deprecated
🛣 Simple Navigation for iOS - ⚠️ Deprecated
Stars: ✭ 458 (+332.08%)
Mutual labels:  navigation, routing

routing-py

tests Coveralls coverage Documentation Status MyBinder.org

One lib to route them all - routingpy is a Python 3 client for several popular routing webservices.

Inspired by geopy and its great community of contributors, routingpy enables easy and consistent access to third-party spatial webservices to request route directions, isochrones or time-distance matrices.

routingpy currently includes support for the following services:

This list is hopefully growing with time and contributions by other developers. An up-to-date list is always available in our documentation.

routing-py is tested against CPython versions 3.7, 3.8, 3.9, 3.10 ~~and against PyPy3~~ ([#60](#60).

© routing-py contributors 2022 under the Apache 2.0 License.

routing-py-image

Why routing-py?

You want to

  • get from A to B by transit, foot, bike, car or hgv
  • compute a region of reachability
  • calculate a time distance matrix for a N x M table

and don't know which provider to use? Great. Then routingpy is exactly what you're looking for.

For the better or worse, every provider works on different spatial global datasets and uses a plethora of algorithms on top. While Google or HERE build on top of proprietary datasets, providers such as Mapbox or Graphhopper consume OpenStreetMap data for their base network. Also, all providers offer a different amount of options one can use to restrict the wayfinding. Ultimately this means that results may differ - and our experience tells us: they do, and not too little. This calls for a careful evaluation which service provider to use for which specific use case.

With routingpy we have made an attempt to simplify this process for you.

Installation

PyPI version

Recommended: Install via poetry:

poetry add routingpy

Install using pip with

pip install routingpy

Or the lastest from source

pip install git+git://github.com/gis-ops/routing-py

API

Every provider has its own specifications and features. However the basic blueprints are the same across all. We tried hard to make the transition from one provider to the other as seamless as possible. We follow two dogmas for all implementations:

  • All basic parameters have to be the same for all routers for each endpoint
  • All routers still retain their special parameters for their endpoints, which make them unique in the end

This naturally means that usually those basic parameters are not named the same way as the endpoints they query. However, all provider specific parameters are named the exact same as their remote counterparts.

The following table gives you an overview which basic arguments are abstracted:

Endpoint Argument Function
directions locations
Specify the locations to be visited in order. Usually this
is done with [Lon, Lat] tuples, but some routers offer
additional options to create a location element.
profile
The mode of transport, i.e. car, bicycle, pedestrian. Each
router specifies their own profiles.
isochrones locations
Specify the locations to calculate isochrones for. Usually
this is done with [Lon, Lat] tuples, but some routers
offer additional options to create a location element.
profile
The mode of transport, i.e. car, bicycle, pedestrian. Each
router specifies their own profiles.
intervals
The ranges to calculate isochrones for. Either in seconds
or in meters, depending on interval_type.
intervals _type
The dimension of intervals, which takes router
dependent values, but generally describes time or distance
matrix locations
Specify all locations you want to calculate a matrix
for. If sources or destinations is not set, this
will return a symmetrical matrix. Usually this is done
with [Lon, Lat] tuples, but some routers offer
additional options to create a location element.
profile
The mode of transport, i.e. car, bicycle, pedestrian. Each
router specifies their own profiles.
sources
The indices of the locations parameter iterable to
take as sources for the matrix calculation. If not
specified all locations are considered to be sources.
destinations
The indices of the locations parameter iterable to
take as destinations for the matrix calculation. If not
specified all locations are considered to be
destinations.

Contributing

We ❤️ contributions and realistically think that's the only way to support and maintain most routing engines in the long run. To get you started, we created a Contribution guideline.

Examples

Follow our examples to understand how simple routingpy is to use.

On top of the examples listed below, find interactive notebook(s) on mybinder.org.

Basic Usage

Get all attributes

routingpy is designed to take the burden off your shoulder to parse the JSON response of each provider, exposing the most important information of the response as attributes of the response object. The actual JSON is always accessible via the raw attribute:

from routingpy import MapboxValhalla
from pprint import pprint

# Some locations in Berlin
coords = [[13.413706, 52.490202], [13.421838, 52.514105],
          [13.453649, 52.507987], [13.401947, 52.543373]]
client = MapboxValhalla(api_key='mapbox_key')

route = client.directions(locations=coords, profile='pedestrian')
isochrones = client.isochrones(locations=coords[0], profile='pedestrian', intervals=[600, 1200])
matrix = client.matrix(locations=coords, profile='pedestrian')

pprint((route.geometry, route.duration, route.distance, route.raw))
pprint((isochrones.raw, isochrones[0].geometry, isochrones[0].center, isochrones[0].interval))
pprint((matrix.durations, matrix.distances, matrix.raw))

Multi Provider

Easily calculate routes, isochrones and matrices for multiple providers:

from routingpy import Graphhopper, ORS, MapboxOSRM
from shapely.geometry import Polygon

# Define the clients and their profile parameter
apis = (
   (ORS(api_key='ors_key'), 'cycling-regular'),
   (Graphhopper(api_key='gh_key'), 'bike'),
   (MapboxOSRM(api_key='mapbox_key'), 'cycling')
)
# Some locations in Berlin
coords = [[13.413706, 52.490202], [13.421838, 52.514105],
          [13.453649, 52.507987], [13.401947, 52.543373]]

for api in apis:
    client, profile = api
    route = client.directions(locations=coords, profile=profile)
    print("Direction - {}:\n\tDuration: {}\n\tDistance: {}".format(client.__class__.__name__,
                                                                   route.duration,
                                                                   route.distance))
    isochrones = client.isochrones(locations=coords[0], profile=profile, intervals=[600, 1200])
    for iso in isochrones:
        print("Isochrone {} secs - {}:\n\tArea: {} sqm".format(client.__class__.__name__,
                                                               iso.interval,
                                                               Polygon(iso.geometry).area))
    matrix = client.matrix(locations=coords, profile=profile)
    print("Matrix - {}:\n\tDurations: {}\n\tDistances: {}".format(client.__class__.__name__,
                                                                  matrix.durations,
                                                                  matrix.distances))

Dry run - Debug

Often it is crucial to examine the request before it is sent. Mostly useful for debugging:

from routingpy import ORS

client = ORS(api_key='ors_key')
route = client.directions(
    locations = [[13.413706, 52.490202], [13.421838, 52.514105]],
    profile='driving-hgv',
    dry_run=True
)

Advanced Usage

Local instance of FOSS router

All FOSS routing engines can be run locally, such as openrouteservice, Valhalla, OSRM and GraphHopper. To be able to use routingpy with a local installation, just change the base_url of the client. This assumes that you did not change the URL(s) of the exposed endpoint(s):

from routingpy import Valhalla

# no trailing slash, api_key is not necessary
client = Valhalla(base_url='http://localhost:8088/v1')

Proxies, Rate limiters and API errors

Proxies are easily set up using following requests scheme for proxying. Also, when batch requesting, routingpy can be set up to resume its requests when the remote API rate limits (i.e. responds with HTTP 429). Also, it can be set up to ignore API errors and instead print them as warnings to stdout. Be careful, when ignoring RouterApiErrors, those often count towards your rate limit.

All these parameters, and more, can optionally be globally set for all router modules or individually per instance:

from routingpy import Graphhopper, ORS
from routingpy.routers import options

request_kwargs = dict(proxies=dict(https='129.125.12.0'))

client = Graphhopper(
    api_key='gh_key',
    retry_over_query_limit=False,
    skip_api_error=True,
    requests_kwargs=request_kwargs
)

# Or alternvatively, set these options globally:
options.default_proxies = {'https': '129.125.12.0'}
options.default_retry_over_query_limit = False
options.default_skip_api_error = True
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].