Skip to main content

High-level bindings to the Valhalla C++ library

Project description

Valhalla for Python

Master Push

This spin-off project simply offers packaged Python bindings to the fantastic Valhalla project.

Over time we will very likely deviate from Valhalla's own Python binding code to allow usages outside the scope of the core project. Refer to our release pattern to learn more about the versioning of this project.

Note, the performance boost using these bindings compared to requesting an HTTP service is tremendous: on 500 random routes in Berlin, the bindings take 27 secs while HTTP on localhost takes 127 secs.

Installation

pypi version

We distribute all currently maintained CPython versions as binary wheels for Win64, MacOS (Intel) and x86_64 Linux distributions with glibc>=2.28. We do not offer a source distribution on PyPI. Please contact us on enquiry@gis-ops.com if you need support building the bindings for your platform/distribution.

pip install pyvalhalla

Note, to install from PyPI as a Linux user you must have pip version 20.3 or greater installed.

Usage

Find a more extended notebook in ./examples, e.g. how to use the actor.

Before using the Python bindings you need to have access to a routable Valhalla graph. Either install Valhalla from source and built the graph from OSM compatible data or use our Valhalla docker image for a painless experience, e.g. this will build the routing graph for Andorra in ./custom_files:

docker run --rm --name valhalla_gis-ops -p 8002:8002 -v $PWD/custom_files:/custom_files -e tile_urls=https://download.geofabrik.de/europe/andorra-latest.osm.pbf gisops/valhalla:latest

Once you have created a graph locally, you can use it like this:

from valhalla import Actor, get_config, get_help

# generate configuration
config = get_config(tile_extract='./custom_files/valhalla_tiles.tar', verbose=True)

# print the help for specific config items (has the same structure as the output of get_config()
print(get_help()["service_limits"]["auto"]["max_distance"])

# instantiate Actor to load graph and call actions
actor = Actor(config)
route = actor.route({"locations": [...]})

License

pyvalhalla is licensed with GPLv2, see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pyvalhalla-3.2.0-cp311-cp311-win_amd64.whl (2.7 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

pyvalhalla-3.2.0-cp311-cp311-manylinux_2_28_x86_64.whl (7.8 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

pyvalhalla-3.2.0-cp311-cp311-macosx_10_15_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.11 macOS 10.15+ x86-64

pyvalhalla-3.2.0-cp310-cp310-win_amd64.whl (2.7 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

pyvalhalla-3.2.0-cp310-cp310-manylinux_2_28_x86_64.whl (7.8 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

pyvalhalla-3.2.0-cp310-cp310-macosx_10_15_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.10 macOS 10.15+ x86-64

pyvalhalla-3.2.0-cp39-cp39-win_amd64.whl (2.7 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

pyvalhalla-3.2.0-cp39-cp39-manylinux_2_28_x86_64.whl (7.8 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

pyvalhalla-3.2.0-cp39-cp39-macosx_10_15_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

pyvalhalla-3.2.0-cp38-cp38-win_amd64.whl (2.7 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

pyvalhalla-3.2.0-cp38-cp38-manylinux_2_28_x86_64.whl (7.8 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

pyvalhalla-3.2.0-cp38-cp38-macosx_10_15_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

pyvalhalla-3.2.0-cp37-cp37m-win_amd64.whl (2.7 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

pyvalhalla-3.2.0-cp37-cp37m-manylinux_2_28_x86_64.whl (7.8 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.28+ x86-64

pyvalhalla-3.2.0-cp37-cp37m-macosx_10_15_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page