• Stars
    star
    389
  • Rank 110,500 (Top 3 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ The Python API to consume openrouteservice(s) painlessly!
Build status Codecov coverage Documentation Status PyPI version MyBinder

Quickstart

Description

The openrouteservice library gives you painless access to the openrouteservice (ORS) routing API's. It performs requests against our API's for

For further details, please visit:

We also have a repo with a few useful examples here.

For support, please ask our forum.

By using this library, you agree to the ORS terms and conditions.

Requirements

openrouteservice-py is tested against Python 3.6, 3.7, 3.8 and 3.9, and PyPy3.6 and PyPy3.7.

For setting up a testing environment, install poetry first.

For Linux and osx:

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -

For windows:

(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python -

Then create a venv and install the dependencies with poetry:

python -m venv .venv && source .venv/bin/activate
poetry install -vv

Installation

To install from PyPI, simply use pip:

pip install openrouteservice

To install the latest and greatest from source:

pip install git+git://github.com/GIScience/openrouteservice-py@development

Testing

If you want to run the unit tests, see Requirements. cd to the library directory and run:

pytest -v

-v flag for verbose output (recommended).

Usage

For an interactive Jupyter notebook have a look on mybinder.org.

Basic example

import openrouteservice

coords = ((8.34234,48.23424),(8.34423,48.26424))

client = openrouteservice.Client(key='') # Specify your personal API key
routes = client.directions(coords)

print(routes)

For convenience, all request performing module methods are wrapped inside the client class. This has the disadvantage, that your IDE can't auto-show all positional and optional arguments for the different methods. And there are a lot!

The slightly more verbose alternative, preserving your IDE's smart functions, is

import openrouteservice
from openrouteservice.directions import directions

    coords = ((8.34234,48.23424),(8.34423,48.26424))

    client = openrouteservice.Client(key='') # Specify your personal API key
    routes = directions(client, coords) # Now it shows you all arguments for .directions

Optimize route

If you want to optimize the order of multiple waypoints in a simple Traveling Salesman Problem, you can pass a optimize_waypoints parameter:

import openrouteservice

coords = ((8.34234,48.23424),(8.34423,48.26424), (8.34523,48.24424), (8.41423,48.21424))

client = openrouteservice.Client(key='') # Specify your personal API key
routes = client.directions(coords, profile='cycling-regular', optimize_waypoints=True)

print(routes)

Decode Polyline

By default, the directions API returns encoded polylines. To decode to a dict, which is a GeoJSON geometry object, simply do

import openrouteservice
from openrouteservice import convert

coords = ((8.34234,48.23424),(8.34423,48.26424))

client = openrouteservice.Client(key='') # Specify your personal API key

# decode_polyline needs the geometry only
geometry = client.directions(coords)['routes'][0]['geometry']

decoded = convert.decode_polyline(geometry)

print(decoded)

Dry run

Although errors in query creation should be handled quite decently, you can do a dry run to print the request and its parameters:

import openrouteservice

coords = ((8.34234,48.23424),(8.34423,48.26424))

client = openrouteservice.Client()
client.directions(coords, dry_run='true')

Local ORS instance

If you're hosting your own ORS instance, you can alter the base_url parameter to fit your own:

import openrouteservice

coords = ((8.34234,48.23424),(8.34423,48.26424))

# key can be omitted for local host
client = openrouteservice.Client(base_url='http://localhost/ors')

# Only works if you didn't change the ORS endpoints manually
routes = client.directions(coords)

# If you did change the ORS endpoints for some reason
# you'll have to pass url and required parameters explicitly:
routes = client.request(
  url='/new_url',
  post_json={
      'coordinates': coords,
      'profile': 'driving-car',
      'format': 'geojson'
  })

Support

For general support and questions, contact our forum.

For issues/bugs/enhancement suggestions, please use https://github.com/GIScience/openrouteservice-py/issues.

Acknowledgements

This library is based on the very elegant codebase from googlemaps.

More Repositories

1

openrouteservice

๐ŸŒ The open source route planner api with plenty of features.
Java
1,442
star
2

openrouteservice-app

๐Ÿš™ The open source route planner app with plenty of features.
JavaScript
224
star
3

openrouteservice-js

๐Ÿ“Œ The JavaScript API to consume openrouteservice(s) painlessly!
JavaScript
203
star
4

openpoiservice

๐Ÿ“ Openpoiservice is a flask application which hosts a highly customizable points of interest database derived from OpenStreetMap data.
Python
171
star
5

GIScene.js

3D WebGIS framework. Based on Three.js. Easy to learn and customize. For examples and API see:
JavaScript
116
star
6

oshdb

OpenStreetMap History Data Analysis Framework
Java
110
star
7

ors-map-client

Openrouteservice API web SPA client using VueJS, Vuetify and Vue2Leaflet
JavaScript
108
star
8

Leaflet.Heightgraph

Leaflet plugin to visualize height information and road attributes.
JavaScript
100
star
9

orstools-qgis-plugin

Plugin for QGIS with a set of tools to use openrouteservice APIยดs, based on openstreetmap
Python
96
star
10

openrouteservice-r

๐ŸŒ query openrouteservice API from R
R
93
star
11

helios

HELIOS - the Heidelberg LiDAR Operations Simulator - is a software package for interactive real-time simulation and visualisation of terrestrial, mobile and airborne laser scan surveys written in Java.
Java
85
star
12

openrouteservice-examples

๐Ÿ“š (Mostly) real-world examples and inspirations to use the full breadth of ORS services and clients
Jupyter Notebook
84
star
13

openrouteservice-docs

๐Ÿ“ This repository stores the swagger specifications of the openrouteservice API. Browse to swagger for a detailed overview.
63
star
14

openelevationservice

๐ŸŒ„ A GeoJSON based service to query SRTM elevation for points/lines.
Python
63
star
15

openrouteservice-app-legacy

OpenRouteService is an online route planning application that is based on open source software, open data and open standards.
JavaScript
55
star
16

ohsome2label

Historical OpenStreetMap Objects to Machine Learning Training Samples
Python
48
star
17

ohsome-api

API for analysing OpenStreetMap history data
Java
44
star
18

OSM-realtime-update

๐Ÿ•‘ OpenStreetMap Data Extracts - updated on the fly!
JavaScript
41
star
19

ohsome-quality-api

Data quality estimations for OpenStreetMap
Python
34
star
20

sketch-map-tool

Create re-digitizable paper maps for offline data collection in the field.
Python
32
star
21

openfuelservice

๐Ÿš—โ˜๏ธ๐Ÿ’ธ The opensource vehicle fuel consumption, emission and cost calculator api
Python
17
star
22

ohsome-py

Python bindings for the ohsome API
Jupyter Notebook
17
star
23

vostok

VOSTOK, the Voxel Octree Solar Toolkit, is a C++ command-line tool to compute a detailed model of incoming solar radiation distribution on a patch of land, including structures like buildings and vegetation, represented by a 3D point cloud data set.
C++
15
star
24

osmatrix-client

OSMatrix is a web-based application to visualize characteristics of OpenStreetMap, which are usually not displayed in cartographic representations of the data.
Python
14
star
25

ohsome-r

This ohsome R package grants access to the power of the ohsome API from R.
R
11
star
26

measures-rest

A REST server to provide measures for geospatial datasets
Java
10
star
27

ohsome-examples

A curated list of examples of using the https://github.com/giscience/ohsome-api
Jupyter Notebook
9
star
28

osmgpxmapmatcher

Java
9
star
29

osm-vis-data

Data for OSMvis
8
star
30

osmgpxinclinecalculator

Tools for incline computation with OSM GPX files
Java
7
star
31

gis-training-resource-center

Io
7
star
32

ohsome-dashboard

Web Client for easy access to OSM History and Quality Analyses
JavaScript
7
star
33

ohsome-qgis-plugin

ohsome Qgis plugin
Python
6
star
34

global-urban-building-completeness-analysis

Code related to the paper entitled "Investigating completeness and inequalities in OpenStreetMap: spatio-temporal analysis of global urban building data"
Jupyter Notebook
6
star
35

socialmedia2traffic-api

SocialMedia2Traffic API
Python
6
star
36

osmatrix

JavaScript
5
star
37

ol-print-layout-control

An extension of openlayers Control. It Helps the user to define a map area that fits to the desired output page format and orientation.
TypeScript
5
star
38

ohsome-now-stats-frontend

This is the frontend application for the ohsomeNow stats.
TypeScript
5
star
39

ohsome-now-stats

The goal of this project is to quantify the changes that are happening to the OpenStreetMap (OSM) database every minute.
Jupyter Notebook
5
star
40

ohsome-now-stats-service

This is the REST service for the ohsomeNow stats.
Kotlin
4
star
41

Safer-Route

R
4
star
42

osm-bikeability

Bikeability index based on OpenStreetMap features for european urban areas
Python
4
star
43

Long-term-validation-of-inner-urban-mobility-metrics-derived-from-Twitter

Long-term validation of inner-urban mobility metrics derived from Twitter
Jupyter Notebook
4
star
44

osmalert

OSM Alert: ohsome Alert variant for ISEP 2023
Java
3
star
45

osm-transform

Custom data filtering and enrichment for OpenStreetMap PBF files for a better openrouteservice graph building
C++
3
star
46

openrouteservice-java

โ˜• The Java API to consume openrouteservice(s) painlessly!
3
star
47

ohsome-quality-api-examples

Jupyter Notebook with examples on how to use the OQT API with Python.
Jupyter Notebook
3
star
48

osmgpxpreprocessor

Pre-processing tools for incline computation with OSM GPX files
Java
3
star
49

green-15min-city

HeiGIT's OSS4SDG hackathon submission
HTML
3
star
50

mapswipe-analytics-client

JavaScript
2
star
51

POI-data-matching

Jupyter Notebook
2
star
52

mapswipe-tutorial

JavaScript
2
star
53

ohsome-api-dockerized

Dockerized Version of the ohsome-api
Dockerfile
2
star
54

healthcare-access-idai

Material on an analysis of healthcare access in Mozambique with the impact of cyclone Idai
R
2
star
55

osmgpxfilter

Java
2
star
56

heigit-disaster-portal

Python
2
star
57

OSM_Events

Supplementary Data and Visualizations for the Paper โ€œAn Analysis of the Spatial and Temporal Distribution of Large-Scale Data Production Events in OpenStreetMapโ€
Python
2
star
58

mapswipe-live

JavaScript
1
star
59

giscience2023

Webpage for the Workshop given at the GIScience Conference 2023
SCSS
1
star
60

nairobi-uber-access

HTML
1
star
61

measures-rest-oshdb-docker

Scripts for starting measures for geospatial datasets in docker container, using the OSHDB
Shell
1
star
62

openpoiservice-docker

openpoiservice-docker
Shell
1
star
63

wegovnow

Embeddable Geo-Spatial Data Repository - WeGovNow Data Quality Management System
C
1
star
64

mapswipe-processing

Python
1
star
65

OSMlanduse-BFM

Jupyter Notebook
1
star
66

pybossa-mapswipe-2

HTML
1
star
67

vue2-leaflet-height-graph

Vue2Leaflet plugin to wrap Leaflet.Heightgraph control for Vue applications
JavaScript
1
star
68

mapswipe-analytics-backend

backend workers to generate and enrich mapswipe data and statistics
Python
1
star
69

shop-completeness

HTML
1
star
70

badges

Collection of badges for indicating the state of a project
Shell
1
star
71

osmatrix-processing

No longer maintained: Processing of osmatrix in postgreSQL
Java
1
star
72

hot-tm-critical-numbers

A GIScience Heidelberg project for for the HOT Tasking Manager.
Python
1
star
73

openrouteservice-schema

Repository for schemas used in the ORS
1
star
74

osm-measure-repository

A repository of OpenStreetMap (OSM) measures
Java
1
star
75

measures-rest-sparql

A SPARQL endpoint for the Measures REST OSHDB App framework.
Python
1
star
76

ai-assisted-osm-mapping-stats

Find out the global scale and evolution of AI-assisted mapping in OpenStreetMap
Jupyter Notebook
1
star
77

Jakarta_Thesis_Klipper

Flood Impact Assessment on Road Network and Healthcare Access
Python
1
star
78

ohsome-js-utils

This library contains JavaScript functions to help clients to use the Ohsome-Api for analyzing historical OpenStreetMap data.
TypeScript
1
star
79

ors-config-migration

Tool for migrating ors-config.json files to ors-config.yml
Python
1
star
80

ors-netascore-workshop-agile-24

Workshop at AGILE 2024
CSS
1
star
81

openrouteservice-workshop-r

Repo to run an openrouteserice workshop via R on binder
HTML
1
star