Skip to content

Instantly share code, notes, and snippets.

View aoles's full-sized avatar

Andrzej K. Oleś aoles

View GitHub Profile
@aoles
aoles / barrier_access_taginfo.R
Created October 7, 2021 10:02
Query taginfo for barrier access values unknown to ORS
library(jsonlite)
# retrieve all possible node access values which come up at least 10 times
url <- "https://taginfo.openstreetmap.org/api/4/key/values?key=%s&filter=nodes&sortname=count&sortorder=desc&qtype=value&format=json_pretty"
key <- "access"
res <- fromJSON(sprintf(url, key))
df <- res[["data"]]
# filter out combined and rare values
@aoles
aoles / weightings.R
Created November 24, 2020 10:07
Priority weightings compared
PRIORITY_CODE = c(
WORST = 0,
AVOID_AT_ALL_COSTS = 1,
REACH_DEST = 2,
AVOID_IF_POSSIBLE = 3,
UNCHANGED = 4,
PREFER = 5,
VERY_NICE = 6,
BEST = 7
)
@aoles
aoles / app.R
Last active June 15, 2020 12:03
Shiny app for comparing ORS cycling weighting alternatives https://aoles.shinyapps.io/cyclingWeightings/
library(shiny)
library(leaflet)
library(openrouteservice)
library(lubridate) #convert seconds to hh:mm
# Precomputed random routes in Bayern
load("routes.rda")
lapply(res, function(routes) {
sapply(routes, function(x) x$features[[1]]$properties$summary$distance/1000)
@aoles
aoles / mannheim.sh
Created October 25, 2018 10:32
Sample script for creating geographic extracts of OSM data
#!/bin/bash
URL=https://download.geofabrik.de/europe/germany/baden-wuerttemberg/karlsruhe-regbez-latest.osm.pbf
RELATION_ID=62691
RELATION_NAME=mannheim
###
echo "Downloading $URL"
SOURCE=$(basename "$URL")
curl $URL -o $SOURCE
@aoles
aoles / bash.Rmd
Created October 8, 2018 10:09
Save bash code chunks in R Markdown documents into separate script files
---
output: html_document
---
```{r setup, include=FALSE}
knit_hooks_source <- knitr::knit_hooks$get("source")
knitr::knit_hooks$set(source = function (x, options) {
if (!is.null(options$save))
writeLines(x, options$save)
knit_hooks_source(x, options)
@aoles
aoles / app.R
Last active April 1, 2021 23:53
ORS isochrones demo Shiny app https://aoles.shinyapps.io/isochrones
library(shiny)
library(leaflet)
library(openrouteservice)
ui <- bootstrapPage(
includeScript("busy_indicator.js"),
includeScript("lazy_sliders.js"),
includeCSS("style.css"),
leafletOutput("map", width = "100%", height = "100%"),
absolutePanel(top = 10, right = 10, id="controls",
@aoles
aoles / app.R
Last active April 1, 2021 23:44
ORS directions demo Shiny app https://aoles.shinyapps.io/directions
library(shiny)
library(leaflet)
library(openrouteservice)
## User interface definition
ui <- bootstrapPage(
includeScript("busy_indicator.js"),
includeCSS("style.css"),
leafletOutput("map", width = "100%", height = "100%"),
absolutePanel(top = 10, right = 10, id="controls",
---
title: "London Blitz Bombs"
author: "Andrzej K. Oleś"
output: html_document
---
```{r config, include=FALSE}
## set up knitr defaults
knitr::opts_chunk$set(eval=TRUE, out.width='100%', out.height='560px')
```
---
title: "London Blitz Bombs"
author: "Andrzej K. Oleś"
output: html_document
---
```{r config, include=FALSE}
## set up knitr defaults
knitr::opts_chunk$set(eval=TRUE, out.width='100%', out.height='560px')
```