README.md

routes

Travis build
status

This repo is the home of an R package that helps me create routes. 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.

Installation

You can install the development version from GitHub with:

# 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, then run:

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():

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.

# Building a route landscape from Corvallis, OR to Portland, OR

# Step 1: Get the route coordinates
routes::route(from = "Corvallis, OR",
  to = "Portland, OR", shortname = "oregon")

# Step 2: Get the StreetView images
routes::streetview(from = "Corvallis, OR",
  to = "Portland, OR", shortname = "oregon")

# Step 3: Cluster, count and plot the colors
routes::cluster(from = "Corvallis, OR",
  to = "Portland, OR", shortname = "oregon")

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/. In particular, you can see the result of Knitting the steps in the following files:

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.



cwickham/routes documentation built on Nov. 4, 2019, 9:34 a.m.