https://github.com/cwickham/routes
R code for creating data art pieces documenting journeys
https://github.com/cwickham/routes
Last synced: over 1 year ago
JSON representation
R code for creating data art pieces documenting journeys
- Host: GitHub
- URL: https://github.com/cwickham/routes
- Owner: cwickham
- License: other
- Created: 2019-07-15T19:09:50.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-07T15:17:01.000Z (almost 7 years ago)
- Last Synced: 2025-02-27T10:38:36.960Z (over 1 year ago)
- Language: R
- Homepage: https://routes.cwick.co.nz
- Size: 8.46 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# routes
[](https://travis-ci.org/cwickham/routes)

This repo is the home of an R package that helps me create [routes](https://routes.cwick.co.nz). It is provided with minimal documentation and no guarantees.
If you would like me to create something for you, or you just want a print of something I've already made, head to my [Etsy store](https://www.etsy.com/shop/dataroutes).
## Installation
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("remotes")
remotes::install_github("cwickham/routes")
```
## Google API
routes assumes you have a Google API key stored in the environment variable `GOOGLE_API_KEY`. Get an [API key from google](https://developers.google.com/maps/documentation/streetview/get-api-key), then run:
```{r, eval = FALSE}
usethis::edit_r_environ()
```
to open your `.Renviron` file and add a line of the form:
```
GOOGLE_API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
```
## Getting started
Open a new RStudio project and run `setup()`:
```{r, message = FALSE, results='hide'}
routes::setup(from = "Corvallis, OR", to = "Portland, OR",
shortname = "oregon")
```
You need to specify `from` and `to` as strings understandable to Google Maps as locations. `setup()` creates a folder called `shortname/` and creates a `00-setup.R` file inside this directory. (*routes uses `here::here()` extensively in its templates under the assumption that `shortname/` is in the root directory of your project*).
`00-setup.R` will open for editing. You will see the three required steps for creating a route.
```{r, code = readLines("oregon/00-setup.R"), eval = FALSE}
```
Run each step to create and open a new file, run the code in the file to complete the step.
An example of running through these steps can be found in [`oregon/`](oregon/). In particular, you can see the result of Knitting the steps in the following files:
* [`01-route`](oregon/01-route.md)
* [`02-streetview`](oregon/02-streetview.md)
* [`03-cluster`](oregon/03-cluster.md)
```{r, include = FALSE, eval = FALSE}
# Run to regenerate `oregon/` example
routes::setup(from = "Corvallis, OR", to = "Portland, OR",
shortname = "oregon")
source(here::here("oregon", "00-setup.R"))
rmarkdown::render(here::here("oregon", "01-route.Rmd"))
rmarkdown::render(here::here("oregon", "02-streetview.Rmd"))
rmarkdown::render(here::here("oregon", "03-cluster.Rmd"))
fs::file_copy(here::here("oregon", "oregon_route.jpeg"),
here::here("man/figures/README-oregon_route.jpeg"),
overwrite = TRUE)
```
## Crediting my work
I've provided this package publicly because I'd love you to create your own artworks. If you do, please credit me for the original code, and support me by sending people to my [Etsy store](https://www.etsy.com/shop/dataroutes).