Learn R Programming

valh

Interface Between R and the OpenStreetMap-Based Routing Service Valhalla

Description

Valhalla is a routing service that is based on OpenStreetMap data. This package provides an interface to the Valhalla API from R. It allows you to query the Valhalla API for routes, isochrones, time-distance matrices, nearest point on the road network, and elevation data.

This package relies on the usage of a running Valhalla service (tested with v3.4.x-3.5.x of Valhalla).

Features

  • vl_route(): Get route between locations.
  • vl_matrix(): Get travel time matrices between points.
  • vl_locate(): Get the nearest point on the road network.
  • vl_elevation(): Get elevation data at given location(s).
  • vl_isochrone(): Get isochrone polygons.
  • vl_optimized_route(): Get optimized route between locations.
  • vl_status(): Get information on Valhalla service.

Installation

  • Development version from GitHub:
# install.packages("remotes")
remotes::install_github("riatelab/valh")

Motivation & Alternatives

The package is designed to provide an easy-to-use interface to the Valhalla routing service from R. Special care has been taken to support multiple input formats, and the package treats sf objects as first-class citizens in both input and output. Additionally, we have tried to maintain a minimal number of dependencies.

This package offers an API that closely resembles that of the osrm package which provides an R interface to the OSRM routing service.

Note that there are other packages that provide an interface to Valhalla API from R :

  • valhallr: This package is on CRAN, but only allows you to access to some Valhalla services (height, locate and optimized route are notably absent). In addition, it calls on many heavy dependencies to install, whereas valh is particularly light on dependencies. Finally, it doesn’t allow you to work directly with sf objects as input.

  • rvalhalla: This package is not on the CRAN, and while it provides access to various Valhalla services, it only does the heavy lifting needed to easily use the data for two of the services (route and sources_to_target). In addition, it doesn’t allow you to work directly with sf objects as input.

Community Guidelines

One can contribute to the package through pull requests and report issues or ask questions here. See the CONTRIBUTING.md file for detailed instructions.

Copy Link

Version

Install

install.packages('valh')

Monthly Downloads

129

Version

0.1.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Timothée Giraud

Last Published

April 9th, 2025

Functions in valh (0.1.0)

vl_matrix

Get Travel Time Matrices Between Points
valh

Shortest Paths and Travel Time with the OpenStreetMap-Based Routing Service Valhalla
vl_optimized_route

Get the Optimized Route Between Multiple Points
vl_route

Get the Shortest Path Between Two Points
vl_elevation

Get elevation along a route
vl_isochrone

Get isochrones and isodistances from a point
vl_locate

Get the nearest point on the road network
vl_status

Get Valhalla Service Status