Skip to content

Instantly share code, notes, and snippets.

@mpadge
Created October 13, 2017 10:02
Show Gist options
  • Save mpadge/26107d69e845c56528a553b73761a715 to your computer and use it in GitHub Desktop.
Save mpadge/26107d69e845c56528a553b73761a715 to your computer and use it in GitHub Desktop.
# download and store the data
library (osmdata)
library (dodgr0
library (bikedata)
bikedir <- "/data/data/bikes"
bikedb <- file.path (bikedir, "all_bike_data.sqlite")
cities <- bike_demographic_data ()$city
dl <- function ()
{
for (ci in cities)
{
message ("----------", ci, "----------")
data_dir <- file.path (bikedir, ci)
n <- dl_bikedata (data_dir = data_dir, city = ci)
n <- store_bikedata (bikedb = bikedb, data_dir = data_dir)
}
index_bikedata_db (bikedb = bikedb)
}
# Calculate distance and trip matrices:
mats <- function ()
{
tripmats <- distmats <- list ()
for (ci in cities)
{
tm <- bike_tripmat (bikedb = bikedb, city = ci,
standardise = TRUE, quiet = FALSE)
dm <- bike_distmat (bikedb = bikedb, city = ci, quiet = FALSE)
tdm <- match_matrices (tm, dm)
tripmats [[ci]] <- tdm$trip
distmats [[ci]] <- tdm$dist
}
save (tripmats, file = paste0 (bikedir, "tripmats.rda"))
save (distmats, file = paste0 (bikedir, "distmats.rda"))
}
dl ()
mats ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment