library(tidyverse)
library(routes)
library(here)
max_images <- 50 # download at most this many images
route_lat_lon <- read_rds(here("oregon", "data", "route_coords.rds"))

Only get images for at most r max_images points on route:

every_nth <- ceiling(nrow(route_lat_lon)/max_images)

route_lat_lon_sub <- route_lat_lon %>% 
  slice(seq(1, nrow(route_lat_lon), by = every_nth))

Get all Street View images:

route_images <- route_lat_lon_sub %>% 
  mutate(
    image = pmap_chr(list(lat = lat, lon = lon), 
      possibly(get_img, NA_character_), 
      dir = here("oregon", "images"))  
  )

Write out image manifest:

route_images %>% 
  write_rds(here("oregon", "images", "manifest.rds")) %>% 
  write_csv(here("oregon", "images", "manifest.csv"))

Checks

Look at first and last images:

route_images %>% 
  slice(1, n()) %>% 
  pull(image) %>% 
  walk(display_jpeg)


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