Skip to content

cwthom/TargomoR

Repository files navigation

TargomoR

CRAN status Travis-CI Build Status codecov

Overview

The TargomoR package provides an R interface to the Targomo REST API. Use TargomoR to get real travel-time information:

Isochrone Polygons: visualise what 'half an hour away' really looks like, using public transport, driving, cycling or walking.

Travel Routes: visualise up-to-date routing data quickly and simply, with pre-written methods for adding complex data to leaflet maps.

Point-to-Point Times: get travel-time data for a large array of source and target points, in a tidy format ready to feed into further analysis.

Note

This package is being developed with the permission of Targomo, but is not an official product. For more information about Targomo, please see their website, and be aware of their terms and conditions.

See below for information on installing the package, setting up your environment correctly, and using the package.

Installation

TargomoR is on CRAN. You can install it with

install.packages("TargomoR")
library(TargomoR)

Alternatively, to install the latest development version from GitHub please use:

remotes::install_github("cwthom/TargomoR")
library(TargomoR)

Set Up Environment

The functions in TargomoR all rely on having a Targomo API Key. To get yours, please sign up with Targomo.

You'll also need to know what region of the world to use. For example if you're looking for travel-time information in Germany, your region is "westcentraleurope". Find your region. In the examples on this page the region is "britishisles".

You can pass these variables to each function manually if you like, but to avoid this, the functions will default to use the TARGOMO_API_KEY and TARGOMO_REGION environment variables respectively.

To take advantage of this, you can set these variables in an .Renviron file. Use the following snippet to write the variables to the file.

setTargomoVariables(api_key = "<YOUR KEY>", region = "<YOUR REGION>",
                    global = FALSE)

# global = TRUE  will write to .Renviron at Sys.getenv("HOME")
# global = FALSE will write to .Renviron at getwd()

Restart R for these variables to take effect.

Get Travel Time Data

You're now ready to use Targomo to get travel-time and routing data. There are three services currently supported:

For each service there are 3 core functions:

  • getTargomo{service} - returns an sf object containing the requested data.
  • drawTargomo{service} - draws the resultant object on a leaflet map.
  • addTargomo{service} - combines get-ting and draw-ing into a single call.

The draw* and add* functions are provided as a convenience - feel free to create your own drawing functions to put the data onto a map!

There is also support for adding basemaps through addTargomoTiles(). See the vignette on basemaps for more information.

You can also check the capabilities of your Targomo account with getTargomoCapabilities().

Attribution

It's a condition of use of the Targomo services that you attribute the travel time data to them. Full details can be found on their attributions page. To help with this there are two functions in TargomoR:

  • attributionLink - just returns the URL of the attributions page
  • addTargomoAttribution - adds the attribution iframe to a leaflet control, for use with leaflet maps.

It is your responsibility to make sure you comply with the attribution requirements appropriate to your plan.

Contributing

Please note that the 'TargomoR' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.


Logo