-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
116 lines (75 loc) · 5.32 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# TargomoR <a href='https://cwthom.github.io/TargomoR'><img src='man/figures/logo.png' align="right" height="139" /></a>
<!-- badges: start -->
[![CRAN status](https://r-pkg.org/badges/version/TargomoR)](https://CRAN.R-project.org/package=TargomoR)
[![Travis-CI Build Status](https://travis-ci.org/cwthom/TargomoR.svg?branch=master)](https://travis-ci.org/cwthom/TargomoR)
[![codecov](https://codecov.io/gh/cwthom/TargomoR/branch/master/graph/badge.svg)](https://codecov.io/gh/cwthom/TargomoR)
<!-- badges: end -->
## Overview
The `TargomoR` package provides an R interface to the [Targomo REST API](https://targomo.com/developers/). 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](https://www.targomo.com/developers/), and be aware of their [terms and conditions](https://account.targomo.com/legal/terms).**
See below for information on [installing](#installation) the package, setting up your [environment](#set-up-environment) correctly, and [using](#get-travel-time-data) the package.
## Installation {#install}
TargomoR is on CRAN. You can install it with
```{r install-cran, eval=FALSE}
install.packages("TargomoR")
library(TargomoR)
```
Alternatively, to install the latest development version from GitHub please use:
```{r install, eval=FALSE}
remotes::install_github("cwthom/TargomoR")
library(TargomoR)
```
## Set Up Environment {#env}
The functions in TargomoR all rely on having a Targomo API Key. To get yours, please [sign up with Targomo](https://targomo.com/developers/pricing/).
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](https://targomo.com/developers/resources/coverage/). 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.
```{r env, eval=FALSE}
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 {#use}
You're now ready to use Targomo to get travel-time and routing data. There are three services currently supported:
* [Isochrone Polygons](https://targomo.com/developers/services/polygon/)
* [Routing](https://targomo.com/developers/services/routing/)
* [Time](https://targomo.com/developers/services/reachability/)
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](https://cwthom.github.io/TargomoR/articles/Basemaps.html) 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](https://targomo.com/developers/resources/attribution/). 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](https://cwthom.github.io/TargomoR/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.
***
### Logo
* made using [hexsticker](https://github.com/GuangchuangYu/hexSticker) by GuangchuangYu.
* icon: made by [Freepik](https://www.flaticon.com/authors/freepik) from [www.flaticon.com](https://www.flaticon.com/).
* font: [Caveat](https://fonts.google.com/specimen/Caveat) from Google Fonts.