Skip to content

Instantly share code, notes, and snippets.

View szechno's full-sized avatar

mackaszechno szechno

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
-- GTFS Database Schema for DuckDB
-- Based on GTFS Specification v2.0
-- levels.txt
CREATE TABLE levels (
level_id TEXT PRIMARY KEY,
level_index DOUBLE NOT NULL,
level_name TEXT
);
library(readr)
library(dplyr)
library(sf)
library(mapgl)
# download data here: https://roadtraffic.dft.gov.uk/downloads
dft <- read_csv("dft_traffic_counts_aadf_by_direction.csv",
col_types = cols(
count_point_id = col_double(),
ui <-
page_sidebar(
tags$head(
tags$link(
rel="shortcut icon",
href="https://github.com/szechno/wscc_shinyapp/blob/main/favicon.ico?raw=true"
)
),
theme = bs_theme(bootswatch = "simplex",
#  preload functions ----
# server ----
server <- function(input, output, session) {
# bs_themer()
#  selected/clicked esuid we call `v` ----
library(shiny)
library(shinyWidgets)
library(bslib)
library(mapgl)
library(sf)
library(stringr)
library(dplyr)
library(DBI)
library(RSQLite)
library(callr)
library(shiny)
library(shinyWidgets)
library(bslib)
library(mapgl)
library(sf)
library(stringr)
library(dplyr)
library(DBI)
library(RSQLite)
library(callr)
# Improvements:
# add `mode` to get_routes by filtering available highway = *
# 'footway', 'unclassified','service', 'track', 'bridleway', 'path',
# 'residential', 'tertiary', 'primary', 'trunk', 'secondary', 'motorway',
# 'tertiary_link', 'pedestrian', 'cycleway', 'primary_link', 'motorway_link',
# 'trunk_link', 'secondary_link', 'living_street', 'construction', 'services',
# 'proposed', 'busway', 'crossing'
# mode == 'walking'
library(sf)
library(dplyr)
library(readr)
library(tidyr)
library(tidygraph)
library(sfnetworks)
library(stplanr)
library(stringr)
library(purrr)
library(mapview)
# prelim functions
# download oemextract and clean up ----
get_oemextract <- function(wsx = "D:/data_store/Boundaries/county/county.shp"){
message("Warning this will take 5-10 mins")
wsx <- sf::read_sf(wsx) |> dplyr::select(geometry)
wsx_roads <- osmextract::oe_get(
wsx |> st_transform(crs = 4326),
query = "SELECT * FROM 'lines' WHERE highway IN ('footway', 'unclassified',
'service', 'track', 'bridleway', 'path', 'residential', 'tertiary',