{"id":27153407,"url":"https://github.com/riatelab/valh","last_synced_at":"2026-02-18T11:06:20.404Z","repository":{"id":286824468,"uuid":"953877774","full_name":"riatelab/valh","owner":"riatelab","description":"Interface between R and the OpenStreetMap-based routing service Valhalla","archived":false,"fork":false,"pushed_at":"2026-02-04T15:06:45.000Z","size":1024,"stargazers_count":21,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-02-05T02:33:08.195Z","etag":null,"topics":["openstreetmap","r","r-package","routing","valhalla"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/riatelab.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json","zenodo":null}},"created_at":"2025-03-24T08:17:31.000Z","updated_at":"2026-02-04T15:14:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"4260b46c-65ff-4aa5-b928-f7d7899c3701","html_url":"https://github.com/riatelab/valh","commit_stats":null,"previous_names":["riatelab/valh"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/riatelab/valh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riatelab%2Fvalh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riatelab%2Fvalh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riatelab%2Fvalh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riatelab%2Fvalh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riatelab","download_url":"https://codeload.github.com/riatelab/valh/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riatelab%2Fvalh/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29576886,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T08:38:15.585Z","status":"ssl_error","status_checked_at":"2026-02-18T08:38:14.917Z","response_time":162,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["openstreetmap","r","r-package","routing","valhalla"],"created_at":"2025-04-08T16:16:41.805Z","updated_at":"2026-02-18T11:06:20.399Z","avatar_url":"https://github.com/riatelab.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n# valh \u003cimg src=\"man/figures/logo.png\" align=\"right\" width=\"140\"/\u003e\n\n[![CRAN](https://www.r-pkg.org/badges/version/valh)](https://CRAN.R-project.org/package=valh)\n[![R build status](https://github.com/riatelab/valh/actions/workflows/check-standard.yaml/badge.svg)](https://github.com/riatelab/valh/actions)\n[![codecov](https://codecov.io/gh/riatelab/valh/graph/badge.svg)](https://app.codecov.io/gh/riatelab/valh)\n[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n\n[Valhalla](https://valhalla.github.io/valhalla/) is a routing service that is based on OpenStreetMap data.\nThis package provides an interface to the Valhalla API from R.\nIt allows you to query the Valhalla API for routes, isochrones, time-distance matrices,\nnearest point on the road network, and elevation data.\n\nThis package relies on the usage of a [running Valhalla server](https://github.com/riatelab/valh?tab=readme-ov-file#installing-your-own-valhalla-server) (tested with versions 3.4.x, 3.5.x and 3.6.x of Valhalla).\n\n\n\u003cimg src=\"man/figures/map.png\" align=\"center\" width=\"500\"/\u003e  \n\n[code for the map](https://gist.github.com/rCarto/8dfba641b807c20c8cbf72ef8ed0c9c5)\n\n\n## Features \n\n- `vl_route()`: Get route between locations.\n- `vl_matrix()`: Get travel time matrices between points.\n- `vl_locate()`: Get the nearest point on the road network.\n- `vl_elevation()`: Get elevation data at given location(s).\n- `vl_isochrone()`: Get isochrone polygons.\n- `vl_optimized_route()`: Get optimized route between locations.\n- `vl_status()`: Get information on Valhalla service.\n\n## Installation\n\n- Stable version from CRAN:\n```{r}\n#| eval: false\ninstall.packages(\"valh\")\n```\n\n- Development version from the r-universe.\n```{r, eval=FALSE}\ninstall.packages(\"valh\", repos = \"https://riatelab.r-universe.dev\")\n```\n\n\n## Demo\n\nThis is a short overview of the main features of `valh`. The dataset\nused here is shipped with the package, it is a sample of 100 random\npharmacies in Berlin ([© OpenStreetMap\ncontributors](https://www.openstreetmap.org/copyright/en)) stored in a\n[geopackage](https://www.geopackage.org/) file.\n\nIt demonstrates the use of  `vl_matrix`, `vl_route` and `vl_elevation` functions.\n\n```{r}\nlibrary(valh)\nlibrary(sf)\npharmacy \u003c- st_read(system.file(\"gpkg/apotheke.gpkg\", package = \"valh\"), quiet = TRUE)\npharmacy \u003c- pharmacy[1:6, ]\n```\n\nOne of valhalla's strengths is that it allows you to use dynamic costing options at query time.\nFor example, we can compare the travel time between each pharmacy by bicycle:\n\n- with the default bicycle parameters (type of bicycle \"hybrid\" with an average speed\n  of 18 km/h and a propensity to use roads, alongside other vehicles, of 0.5 out of 1 - the\n  default value),\n- with the road bicycle parameters (type of bicycle \"road\" with an average speed of\n  25 km/h and a propensity to use roads, alongside other vehicles, of 1 out of 1).\n\nThese costing options for each costing model ('auto', 'bicycle', etc.) are documented in\n[Valhalla's documentation](https://valhalla.github.io/valhalla/api/turn-by-turn/api-reference/#costing-models).\n\n```{r}\ndefault_bike \u003c- vl_matrix(loc = pharmacy, costing = \"bicycle\")\n\nroad_bike \u003c- vl_matrix(loc = pharmacy, costing = \"bicycle\",\n                       costing_options = list(bicycle_type = \"Road\", use_roads = \"1\"))\n```\n\nThe object returned by `vl_matrix` is a list with 4 elements:\n\n- `sources`: origin point coordinates,\n- `destinations`: destination point coordinates,\n- `distances` : distance matrix between sources and destinations,\n- `durations` : travel time matrix between sources and destinations.\n\n\n```{r}\ndefault_bike$durations\nroad_bike$durations\n```\n\n\nWe can see not only that travel times are different (which is to be expected,\ngiven that we've changed the cyclist's default speed), but also that the path\ntaken are different (as a consequence of the change in preference for using\nroads rather than cycle paths).\n\n```{r}\ndefault_bike$distances - road_bike$distances\n```\n\nWe now calculate a route between two points, by foot, using the `vl_route`\nfunction and calculate the elevation profile of the returned route, using\nthe `vl_elevation` function.\n\n\n```{r, eval = FALSE}\np1 \u003c- pharmacy[3, ]\np2 \u003c- pharmacy[6, ]\nroute \u003c- vl_route(p1, p2, costing = \"pedestrian\")\nplot(st_geometry(route), main = \"Route between 2 pharmacies\")\nplot(c(st_geometry(p1), st_geometry(p2)), pch = 21, cex = 2, add = TRUE)\n```\n\n\n```{r route, echo=FALSE, fig.path=\"man/figures/README-\", fig.width=3, fig.height=4, }\n\np1 \u003c- pharmacy[3, ]\np2 \u003c- pharmacy[6, ]\n\nroute \u003c- vl_route(p1, p2, costing = \"pedestrian\")\npar(mar = c(0, 0, 2, 0))\n# We plot the route and pharmacies\nplot(st_geometry(route), main = \"Route between 2 pharmacies\")\nplot(c(st_geometry(p1), st_geometry(p2)), pch = 21, cex = 2, add = TRUE)\n```\n\n```{r}\n# We transform the LineString to Point geometries\npts_route \u003c- sf::st_cast(st_geometry(route), \"POINT\")\n\nelev \u003c- vl_elevation(loc = pts_route, sampling_dist = 100)\n```\n\nThe object returned is an sf object with a point for each location where the\naltitude has been sampled and with the attributes 'distance' (the cumulative\ndistance to the first point) and 'height' (the altitude).\n\nWe can use it to plot the elevation profile of the route.\n\n```{r elevation, fig.width=7, fig.height=4,  fig.path=\"man/figures/README-\"}\nplot(as.matrix(st_drop_geometry(elev)), type = \"l\", lwd = 2, ylim = c(20, 70), asp = 100,\n     main = \"Elevation Profile\")\n```\n\n\n## Installing your own Valhalla server\n\n`valh` uses the Valhalla demo server by default. The [Valhalla documentation](https://valhalla.github.io/valhalla/#demo-server) states that \"usage of the demo server follows the usual fair-usage policy as OSRM \u0026 Nominatim demo servers (somewhat enforced by [rate limits](https://github.com/valhalla/valhalla/discussions/3373#discussioncomment-1644713))\".  \nThis means that if you want to use Valhalla for a large number of requests, you will need to install it locally or on your own server.  \nTo that end, we have included a [vignette](https://CRAN.R-project.org/package=valh/vignettes/install-valhalla.html) showing how to install\nyour own instance of Valhalla, either locally or on a remote server, using Docker.\n\n## Motivation \u0026 Alternatives\n\nThe package is designed to provide an easy-to-use interface to the Valhalla routing service from R.\nSpecial care has been taken to support multiple input formats, \nand the package treats `sf` objects as first-class citizens in both input and output.\nAdditionally, we have tried to maintain a minimal number of dependencies.   \n\nThis package offers an API that closely resembles that of the [`osrm`](https://github.com/riatelab/osrm)\npackage which provides an R interface to the OSRM routing service.\n\nNote that there are other packages that provide an interface to Valhalla API from R :\n\n- [valhallr](https://github.com/chris31415926535/valhallr/): This package is on CRAN. It provides access to some of Valhalla's services (*height*, *locate* and *optimized route* are notably missing). It depends on a number of rather heavy packages and it does not allow `sf` objects as input.\n- [rvalhalla](https://github.com/Robinlovelace/rvalhalla): This package is not on CRAN. Although it can provide access to several Valhalla services, it only makes it easy to use two of them (*route* and *sources_to_target*). It does not accept `sf` objects as input.\n\n## Community Guidelines\n\nOne can contribute to the package through [pull requests](https://github.com/riatelab/valh/pulls) and\nreport issues or ask questions [here](https://github.com/riatelab/valh/issues).\nSee the [CONTRIBUTING.md](https://github.com/riatelab/valh/blob/master/CONTRIBUTING.md)\nfile for detailed instructions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friatelab%2Fvalh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friatelab%2Fvalh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friatelab%2Fvalh/lists"}