ashton
(code volé à un dude qui a fait la même chose pour les costco à Anchorage, Alaska)
Petit projet avec utilisation de: - osmdata pour trouver les ashton - (new to me) de mapboxapi pour les isochrones - et raster/fasterize pour combiner les multiples isochrones
suppressMessages(
suppressWarnings({
library(mapboxapi)
library(tidyverse)
library(mapdeck)
library(osmdata)
library(leaflet)
library(sf)
library(raster)
library(rgeos)
library(fasterize)
library(rgdal)
library(sf)
library(dplyr)
library(purrr)
library(mapview)
})
)
step 1 : trouver les ashton avec osmdata
#
# mapboxapi::mb_access_token(Sys.getenv("mapbox"),
# install = TRUE,
# overwrite = TRUE)
bb <- getbb("Quebec, QC")
x <- bb %>% opq() %>%
add_osm_feature(key= "name", value = c("ASHTON", "ASTHON"),
value_exact = FALSE, match_case = FALSE
)%>%
osmdata_sf()
mapview::mapview(x$osm_points)
step 2 : trouver les isochrone 1 à 30 minutes de marche autour des ashton
points <- x$osm_points %>%
filter(!(osm_id %in% c(1750439777,1750439789, 1750439808, 1750439833, 1750439845, 1616297363, 1616297367, 1616297399))) ## multiple points for a single greasy spoon
string_latlon <- points %>% st_coordinates() %>% as_tibble() %>% mutate(latlon = paste0( X, ",", Y)) %>% pull(latlon) # this is ugly.. find better way
isochrones <- map(string_latlon,
~ mb_isochrone(location =.x, profile = "walking", time = 1:30 ))
iso_sf <- bind_rows(isochrones)
mapview(iso_sf)