The TargomoR package is designed to be an R interface to the Targomo travel time service, through their REST API. The goal is to make it easy for R users to access the data, so they can spend more time doing analysis and less time wrestling with API documentation.

The functions in TargomoR are designed to integrate with those of leaflet - functions for adding features and tiles to a leaflet map for example all take the form addTargomo*, and can be piped together using %>%.

Underlying the functions to talk to the API is the httr::POST function. Each request is composed by translating your data and options into a suitable JSON request, POSTing it to the API, and processing the JSON response into an sf object.

Services Available

Targomo provides a range of travel-time services as end-points from their API. Currently supported services are detailed in the table below. Please see the linked articles for more information on each service.

Service Key Functions
Basemaps addTargomoTiles(), targomoMapStyles()
Polygons getTargomoPolygons(), drawTargomoPolygons(), addTargomoPolygons(), polygonDrawOptions()
Routes getTargomoRoutes(), drawTargomoRoutes(), addTargomoRoutes(), routeDrawOptions()
Times getTargomoTimes(), drawTargomoTimes(), addTargomoTimes(), timeDrawOptions()
Options (all services) targomoOptions()

As well as the addTargomo* functions there are also separate corresponding getTargomo* and drawTargomo* functions which return the data from the API as a usable R object and draw it on the map (respectively). These provide flexibility, and are particularly useful if you’re conducting further analysis with the data, rather than immediately visualising it.


The following code snippet shows how easy it is to add detailed routing data to a leaflet map, in just a few function calls. Try clicking the red public transport lines for more information about the route!

Check out the detailed articles for more information.