openrouteservice

:snake: The Python API to consume openrouteservice(s) painlessly!

https://github.com/giscience/openrouteservice-py

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.8%) to scientific vocabulary

Keywords

api directions-api geocoding-api isochrones python routing-engine
Last synced: 6 months ago · JSON representation

Repository

:snake: The Python API to consume openrouteservice(s) painlessly!

Basic Info
  • Host: GitHub
  • Owner: GIScience
  • License: apache-2.0
  • Language: Python
  • Default Branch: master
  • Homepage: https://openrouteservice.org
  • Size: 1.69 MB
Statistics
  • Stars: 431
  • Watchers: 14
  • Forks: 62
  • Open Issues: 12
  • Releases: 2
Topics
api directions-api geocoding-api isochrones python routing-engine
Created about 8 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog License Authors

README.rst

.. image:: https://github.com/GIScience/openrouteservice-py/workflows/tests/badge.svg
    :target: https://github.com/GIScience/openrouteservice-py/actions
    :alt: Build status

.. image:: https://codecov.io/gh/GIScience/openrouteservice-py/branch/master/graph/badge.svg?token=QqGC8XfCiI
    :target: https://codecov.io/gh/GIScience/openrouteservice-py
    :alt: Codecov coverage

.. image:: https://readthedocs.org/projects/openrouteservice-py/badge/?version=latest
   :target: http://openrouteservice-py.readthedocs.io/en/latest/?badge=latest
   :alt: Documentation Status

.. image:: https://badge.fury.io/py/openrouteservice.svg
    :target: https://badge.fury.io/py/openrouteservice
    :alt: PyPI version

.. image:: https://mybinder.org/badge_logo.svg
    :target: https://mybinder.org/v2/gh/GIScience/openrouteservice-py/master?filepath=examples%2Fbasic_example.ipynb
    :alt: 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

- directions_
- isochrones_
- `matrix routing calculations`_
- places_
- elevation_
- `Pelias geocoding`_
- `Pelias reverse geocoding`_
- `Pelias structured geocoding`_
- `Pelias autocomplete`_
- Optimization_

For further details, please visit:

- homepage_
- `ORS API documentation`_
- `openrouteservice-py documentation`_

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`_.

.. _openrouteservice: https://openrouteservice.org
.. _homepage: https://openrouteservice.org
.. _`ORS API documentation`: https://openrouteservice.org/documentation/
.. _`openrouteservice-py documentation`: http://openrouteservice-py.readthedocs.io/en/latest/
.. _directions: https://openrouteservice.org/documentation/#/reference/directions/directions/directions-service
.. _`Pelias geocoding`: https://github.com/pelias/documentation/blob/master/search.md#available-search-parameters
.. _`Pelias reverse geocoding`: https://github.com/pelias/documentation/blob/master/reverse.md#reverse-geocoding-parameters
.. _`Pelias structured geocoding`: https://github.com/pelias/documentation/blob/master/structured-geocoding.md
.. _`Pelias autocomplete`: https://github.com/pelias/documentation/blob/master/autocomplete.md
.. _isochrones: https://openrouteservice.org/documentation/#/reference/isochrones/isochrones/isochrones-service
.. _elevation: https://github.com/GIScience/openelevationservice/
.. _`reverse geocoding`: https://openrouteservice.org/documentation/#/reference/geocoding/geocoding/geocoding-service
.. _`matrix routing calculations`: https://openrouteservice.org/documentation/#/reference/matrix/matrix/matrix-service-(post)
.. _places: https://github.com/GIScience/openpoiservice
.. _Optimization: https://github.com/VROOM-Project/vroom/blob/master/docs/API.md
.. _here: https://github.com/GIScience/openrouteservice-examples/tree/master/python
.. _`terms and conditions`: https://openrouteservice.org/terms-of-service/
.. _forum: https://ask.openrouteservice.org/c/sdks

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
^^^^^^^^^^^^^^^^^^^^
.. code:: python

	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

.. code:: python

    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:

.. code:: python

	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

.. code:: python

    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:

.. code:: python

    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:

.. code:: python

    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.


.. _forum: https://ask.openrouteservice.org/c/sdks


Acknowledgements
-----------------

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


.. _googlemaps: https://github.com/googlemaps/google-maps-services-python

Owner

  • Name: GIScience Research Group and HeiGIT
  • Login: GIScience
  • Kind: organization
  • Location: Heidelberg, Germany

🌍 HeiGIT and GIScience at Heidelberg University are engaged in research and opensource development at the interface between geography and computational science

GitHub Events

Total
  • Issues event: 5
  • Watch event: 34
  • Issue comment event: 4
  • Push event: 2
  • Pull request review event: 1
  • Fork event: 6
Last Year
  • Issues event: 5
  • Watch event: 34
  • Issue comment event: 4
  • Push event: 2
  • Pull request review event: 1
  • Fork event: 6

Committers

Last synced: 11 months ago

All Time
  • Total Commits: 205
  • Total Committers: 13
  • Avg Commits per committer: 15.769
  • Development Distribution Score (DDS): 0.698
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
nilsnolde n****s@o****g 62
nilsnolde n****e@g****m 52
Nils n****e@g****m 28
isikl i****l@o****g 16
Julian Psotta 2****P 15
isabell 3****l 13
ri0t r****t@c****g 9
Jakob Schnell J****l@h****g 4
Timothy m****e@g****m 2
Vincenzo Lavorini v****i@p****h 1
Johannes Visintini j****i@h****g 1
JeromeHoen 4****n 1
James Addison j****y@j****t 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 49
  • Total pull requests: 48
  • Average time to close issues: 3 months
  • Average time to close pull requests: 2 months
  • Total issue authors: 22
  • Total pull request authors: 16
  • Average comments per issue: 1.14
  • Average comments per pull request: 1.33
  • Merged pull requests: 35
  • Bot issues: 0
  • Bot pull requests: 5
Past Year
  • Issues: 3
  • Pull requests: 1
  • Average time to close issues: about 3 hours
  • Average time to close pull requests: N/A
  • Issue authors: 3
  • Pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • nilsnolde (15)
  • MichaelsJP (11)
  • stefanocudini (2)
  • swissembedded (2)
  • koebi (2)
  • flavsind (1)
  • pareyesv (1)
  • Aaron-JE (1)
  • djqifs (1)
  • riccardoklinger (1)
  • RafaelAbel (1)
  • cpprofs (1)
  • TimMcCauley (1)
  • bromosky (1)
  • iliastsergoulas (1)
Pull Request Authors
  • MichaelsJP (13)
  • nilsnolde (7)
  • koebi (5)
  • isikl (5)
  • jarinox (4)
  • dependabot[bot] (4)
  • vlavorini (2)
  • DiyanIvanov (1)
  • jayaddison (1)
  • claudep (1)
  • clarkerubber (1)
  • JeromeHoen (1)
  • ri0t (1)
  • joker234 (1)
  • kenspeckle1 (1)
Top Labels
Issue Labels
enhancement (8) bug (6) good first issue (2) has workaround (2) invalid (1) wontfix (1) PyPI (1) ORS (1)
Pull Request Labels
dependencies (4) bug (2) enhancement (1)

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 37,824 last-month
  • Total docker downloads: 36
  • Total dependent packages: 3
    (may contain duplicates)
  • Total dependent repositories: 75
    (may contain duplicates)
  • Total versions: 57
  • Total maintainers: 2
pypi.org: openrouteservice

Python client for requests to openrouteservice API services

  • Versions: 23
  • Dependent Packages: 3
  • Dependent Repositories: 75
  • Downloads: 37,824 Last month
  • Docker Downloads: 36
Rankings
Dependent repos count: 1.7%
Downloads: 2.1%
Dependent packages count: 2.3%
Average: 3.2%
Stargazers count: 3.5%
Docker downloads count: 3.5%
Forks count: 5.9%
Maintainers (2)
Last synced: 6 months ago
proxy.golang.org: github.com/GIScience/openrouteservice-py
  • Versions: 17
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Stargazers count: 3.3%
Forks count: 3.5%
Average: 4.5%
Dependent packages count: 5.4%
Dependent repos count: 5.7%
Last synced: 6 months ago
proxy.golang.org: github.com/giscience/openrouteservice-py
  • Versions: 17
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.7%
Last synced: 6 months ago

Dependencies

poetry.lock pypi
  • appdirs 1.4.4 develop
  • atomicwrites 1.4.0 develop
  • attrs 21.2.0 develop
  • cfgv 3.0.0 develop
  • colorama 0.4.4 develop
  • coverage 5.5 develop
  • distlib 0.3.1 develop
  • filelock 3.0.12 develop
  • identify 1.6.2 develop
  • importlib-metadata 4.0.1 develop
  • importlib-resources 5.1.4 develop
  • iniconfig 1.1.1 develop
  • nodeenv 1.6.0 develop
  • packaging 20.9 develop
  • pluggy 0.13.1 develop
  • pre-commit 2.1.1 develop
  • py 1.10.0 develop
  • pyparsing 2.4.7 develop
  • pytest 6.2.4 develop
  • pytest-cov 2.12.0 develop
  • pyyaml 5.4.1 develop
  • tox 3.23.1 develop
  • typing-extensions 3.10.0.0 develop
  • virtualenv 20.4.7 develop
  • yapf 0.31.0 develop
  • zipp 3.4.1 develop
  • certifi 2020.12.5
  • chardet 4.0.0
  • idna 2.10
  • poetry-semver 0.1.0
  • poetry2conda 0.3.0
  • requests 2.25.1
  • responses 0.13.3
  • six 1.16.0
  • toml 0.10.2
  • urllib3 1.26.4
pyproject.toml pypi
  • coverage ^5.4 develop
  • importlib-metadata >=2.1.1 develop
  • pre-commit >=2.1.1 develop
  • pytest >=4.1.0 develop
  • pytest-cov >=2.0.0 develop
  • tox >=3.21.4 develop
  • virtualenv >=20.4.2 develop
  • yapf >=0.30.0 develop
  • poetry2conda ^0.3.0
  • python >=3.6, <4.0
  • requests >=2.0
  • responses >=0.12
.github/workflows/ci-production.yml actions
  • abatilo/actions-poetry v2.1.0 composite
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • codecov/codecov-action v1 composite
.github/workflows/ci-tests.yml actions
  • abatilo/actions-poetry v2.1.0 composite
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • codecov/codecov-action v1 composite
  • pre-commit/action v2.0.0 composite
environment.yml pypi
  • openrouteservice *