Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
citizenair
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vmm
citizenair
Commits
c291b99e
Commit
c291b99e
authored
Nov 08, 2018
by
Jan Wijffels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redesign page 2
parent
42a72a11
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
134 additions
and
81 deletions
+134
-81
citizenair/inst/apps/citizenair/citizenair.Rmd
+55
-1
citizenair/inst/apps/citizenair/page01-introduction.Rmd
+17
-63
citizenair/inst/apps/citizenair/page02-exploratory.Rmd
+62
-17
No files found.
citizenair/inst/apps/citizenair/citizenair.Rmd
View file @
c291b99e
...
@@ -26,10 +26,12 @@ library(sp)
...
@@ -26,10 +26,12 @@ library(sp)
library(xts)
library(xts)
library(dygraphs)
library(dygraphs)
data("BE_ADMIN_REGION", package = "BelgiumMaps.StatBel")
data("BE_ADMIN_REGION", package = "BelgiumMaps.StatBel")
data("ca", package = "citizenair")
dashinput <- list()
dashinput <- list()
dashinput$endpoint <- as.Endpoint("http://geo.irceline.be/sos/api/v1")
dashinput$endpoint <- as.Endpoint("http://geo.irceline.be/sos/api/v1")
dashinput$appdata <- CitizenAir$new(endpoint = dashinput$endpoint)
#dashinput$appdata <- CitizenAir$new(endpoint = dashinput$endpoint)
dashinput$appdata <- ca
dashinput$region <- subset(BE_ADMIN_REGION, TX_RGN_DESCR_NL %in% "Vlaams Gewest")
dashinput$region <- subset(BE_ADMIN_REGION, TX_RGN_DESCR_NL %in% "Vlaams Gewest")
dashinput$stations_sp <- dashinput$appdata$getStations()
dashinput$stations_sp <- dashinput$appdata$getStations()
dashinput$stations_sp <- dashinput$stations_sp[sapply(1:nrow(dashinput$stations_sp),
dashinput$stations_sp <- dashinput$stations_sp[sapply(1:nrow(dashinput$stations_sp),
...
@@ -47,6 +49,58 @@ popups$cleaned_data <- modalDialog(
...
@@ -47,6 +49,58 @@ popups$cleaned_data <- modalDialog(
tags$hr(),
tags$hr(),
DT::dataTableOutput("uiOutput_rawdata", width = "100%", height = "auto"),
DT::dataTableOutput("uiOutput_rawdata", width = "100%", height = "auto"),
size = "l", footer = modalButton("Sluit"), easyClose = TRUE)
size = "l", footer = modalButton("Sluit"), easyClose = TRUE)
citizenair_userdata <- reactive({
input$uiInput_xl
isolate({
default <- data.frame(name = character(), size = integer(), type = character(), datapath = character(), stringsAsFactors = FALSE)
result <- list()
result$stations <- dashinput$stations_sp
result$name <- input$uiInput_xl$name
result$file <- input$uiInput_xl$datapath
result$data <- list()
result$data$phenomena <- character()
result$data$meta <- data.frame(sheet_id = integer(), sheet = character(), device = character(),
lat = numeric(), lon = numeric(),
phenomena = character(), stringsAsFactors = FALSE)
result$data$phenomena <- data.frame(sheet_id = integer(), time = as.POSIXct(character()), date = as.Date(character()),
phenomena = character(), value = numeric(), stringsAsFactors = FALSE)
if(is.null(input$uiInput_xl)){
result$file <- default
}else{
showNotification("We lezen uw Excel bestand in wacht even...")
x <- try(dashinput$appdata$setCitizenData(result$file))
if(inherits(x, "try-error")){
showNotification(sprintf("Er loopt iets fout, is uw data bestand wel een correct bestand? %s", as.character(attributes(x)$condition)))
}else{
x <- dashinput$appdata$data
result$data$polluenten <- x$phenomena
result$data$meta <- as.data.frame(x, type = "meta")
result$data$phenomena <- as.data.frame(x, type = "measurements")
nearest_station <- function(stations, x){
d <- sp::spDistsN1(stations, x, longlat = TRUE)
stations[which.min(d), ]
}
point <- as.matrix(data.frame(lon = 51.20, lat = 4.54))
point <- subset(result$data$meta, !is.na(lon))
if(nrow(point) > 0){
result$nearest_station <- nearest_station(stations = dashinput$stations_sp, as.matrix(point[1, c("lon", "lat")]))
result$nearest_station <- result$nearest_station$id
}else{
result$nearest_station <- character()
}
output$uiOutput_rawmeta <- renderTable(result$data$meta)
output$uiOutput_rawdata <- renderDT(datatable(result$data$phenomena, rownames = FALSE,
caption = 'Overzicht van alle meetgegevens per sheet/tijdstip/type meting',
filter = 'top', options = list(pageLength = 5, autoWidth = TRUE)))
showModal(popups$cleaned_data)
}
}
})
result
})
```
```
# Data {data-icon="fa-cloud-upload"}
# Data {data-icon="fa-cloud-upload"}
...
...
citizenair/inst/apps/citizenair/page01-introduction.Rmd
View file @
c291b99e
...
@@ -13,70 +13,23 @@ output[["citizenair-blank.xls"]] <- downloadHandler(
...
@@ -13,70 +13,23 @@ output[["citizenair-blank.xls"]] <- downloadHandler(
)
)
tags$blockquote("Deze toepassing laat je toe om de kwaliteit van je eigen luchtmeting in te schatten.
tags$blockquote("Deze toepassing laat je toe om de kwaliteit van je eigen luchtmeting in te schatten.
Hiervoor moet je je data plaatsen in het template dat je via", tags$a(href="https://hoemeetiklucht.eu", "www.hoemeetiklucht.eu"), "kan samenstellen.")
Hiervoor moet je je data plaatsen in het template dat je via",
tags$a(href="https://hoemeetiklucht.eu", "www.hoemeetiklucht.eu"),
"kan samenstellen.")
tags$ul(
tags$ul(
tags$li("Download een voorbeeld excel file: ", downloadLink("citizenair-example.xls", "citizenair-example.xls")),
tags$li("Download een voorbeeld excel file: ",
tags$li("Download een lege excel file waarin je je data kan copy-pasten: ", downloadLink("citizenair-blank.xls", "citizenair-blank.xls")),
downloadLink("citizenair-example.xls", "citizenair-example.xls")),
tags$li("Download de handleiding: ", tags$a(href="https://hoemeetiklucht.eu", "hoemeetiklucht.eu"))
tags$li("Download een lege excel file waarin je je data kan copy-pasten: ",
downloadLink("citizenair-blank.xls", "citizenair-blank.xls")),
tags$li("Ga naar de handleiding: ",
tags$a(href="https://hoemeetiklucht.eu", "hoemeetiklucht.eu"))
)
)
```
```
```{r}
```{r}
fileInput("uiInput_xl", label = "Selecteer het bestand met uw metingen: ", accept = "application/excel",
fileInput("uiInput_xl", label = "Selecteer het bestand met uw metingen: ", accept = "application/excel",
buttonLabel = div("excel: ", icon("file-excel-o")), placeholder = "Nog geen bestand geselecteerd")
buttonLabel = div("excel: ", icon("file-excel-o")), placeholder = "Nog geen bestand geselecteerd")
citizenair_userdata <- reactive({
#materialSwitch(inputId = "uiInput_addexcel", label = "Combineer excel met vorige excel", value = FALSE, status = "info")
input$uiInput_xl
isolate({
default <- data.frame(name = character(), size = integer(), type = character(), datapath = character(), stringsAsFactors = FALSE)
result <- list()
result$stations <- dashinput$stations_sp
result$name <- input$uiInput_xl$name
result$file <- input$uiInput_xl$datapath
result$data <- list()
result$data$phenomena <- character()
result$data$meta <- data.frame(sheet_id = integer(), sheet = character(), device = character(),
lat = numeric(), lon = numeric(),
phenomena = character(), stringsAsFactors = FALSE)
result$data$phenomena <- data.frame(sheet_id = integer(), time = as.POSIXct(character()), date = as.Date(character()),
phenomena = character(), value = numeric(), stringsAsFactors = FALSE)
if(is.null(input$uiInput_xl)){
result$file <- default
}else{
showNotification("We lezen uw Excel bestand in wacht even...")
x <- try(dashinput$appdata$setCitizenData(result$file))
if(inherits(x, "try-error")){
showNotification(sprintf("Er loopt iets fout, is uw data bestand wel een correct bestand? %s", as.character(attributes(x)$condition)))
}else{
x <- dashinput$appdata$data
result$data$polluenten <- x$phenomena
result$data$meta <- as.data.frame(x, type = "meta")
result$data$phenomena <- as.data.frame(x, type = "measurements")
nearest_station <- function(stations, x){
d <- sp::spDistsN1(stations, x, longlat = TRUE)
stations[which.min(d), ]
}
point <- as.matrix(data.frame(lon = 51.20, lat = 4.54))
point <- subset(result$data$meta, !is.na(lon))
if(nrow(point) > 0){
result$nearest_station <- nearest_station(stations = dashinput$stations_sp, as.matrix(point[1, c("lon", "lat")]))
result$nearest_station <- result$nearest_station$id
}else{
result$nearest_station <- character()
}
output$uiOutput_rawmeta <- renderTable(result$data$meta)
output$uiOutput_rawdata <- renderDT(datatable(result$data$phenomena, rownames = FALSE,
caption = 'Overzicht van alle meetgegevens per sheet/tijdstip/type meting',
filter = 'top', options = list(pageLength = 5, autoWidth = TRUE)))
showModal(popups$cleaned_data)
}
}
})
result
})
```
```
### Meetstations van de Vlaamse Overheid {data-height=500}
### Meetstations van de Vlaamse Overheid {data-height=500}
...
@@ -91,16 +44,17 @@ output$uiOutput_stations <- renderLeaflet({
...
@@ -91,16 +44,17 @@ output$uiOutput_stations <- renderLeaflet({
map <- addTiles(map)
map <- addTiles(map)
map <- addPolygons(map, weight = 3, fillOpacity = 0)
map <- addPolygons(map, weight = 3, fillOpacity = 0)
map <- addCircleMarkers(map = map, data = stations, radius = 5, opacity = 0.3, fillOpacity = 1, weight = 3,
map <- addCircleMarkers(map = map, data = stations, radius = 5, opacity = 0.3, fillOpacity = 1, weight = 3,
popup = as.character(mapply(label = stations$label, phenomena = stations$phenomena_label,
popup = as.character(mapply(
id = stations$id,
label = stations$label, phenomena = stations$phenomena_label,
FUN=function(label, phenomena){
FUN=function(
id,
label, phenomena){
sprintf("<b>Station
: %s</b> <br>Meetwaardes:<br> %s"
, label, paste(sprintf(" - %s ", phenomena), collapse = "<br>"))
sprintf("<b>Station
%s: %s</b> <br>Meetwaardes:<br> %s", id
, label, paste(sprintf(" - %s ", phenomena), collapse = "<br>"))
})))
})))
if(length(userdata$nearest_station) > 0){
if(length(userdata$nearest_station) > 0){
stations <- subset(stations, id %in% userdata$nearest_station)
stations <- subset(stations, id %in% userdata$nearest_station)
map <- addPopups(map, data = stations, popup = "Dichtstbijzijnd gevalideerd meetstation")
stations <- head(stations, 1)
map <- addPopups(map, data = stations, popup = sprintf("Dichtste meetstation<br>%s: %s", stations$id, stations$label))
}
}
if(nrow(meta) > 0){
if(nrow(meta) > 0){
map <- addPopups(map, lng = meta$lon, lat = meta$lat, popup =
"Uw meetpunten"
)
map <- addPopups(map, lng = meta$lon, lat = meta$lat, popup =
sprintf("<b>Sheet %s: %s</b>", meta$sheet_id, meta$sheet)
)
map <- addCircleMarkers(map, lng = meta$lon, lat = meta$lat, color = "red",
map <- addCircleMarkers(map, lng = meta$lon, lat = meta$lat, color = "red",
popup = sprintf("Sheet: %s\nDevice: %s", meta$sheet, meta$device),
popup = sprintf("Sheet: %s\nDevice: %s", meta$sheet, meta$device),
radius = 5, weight = 3, fillOpacity = 1)
radius = 5, weight = 3, fillOpacity = 1)
...
@@ -192,7 +146,7 @@ renderTable({
...
@@ -192,7 +146,7 @@ renderTable({
x <- x[order(n, decreasing=TRUE), ]
x <- x[order(n, decreasing=TRUE), ]
x <- merge(x, userdata$data$meta, by = "sheet_id")
x <- merge(x, userdata$data$meta, by = "sheet_id")
x <- as.data.frame(x)
x <- as.data.frame(x)
x <- x[!duplicated(x$sheet_id), c("sheet_id", "device", "meetfrequentie"
, "n", "pct"
)]
x <- x[!duplicated(x$sheet_id), c("sheet_id", "device", "meetfrequentie")]
x$meetfrequentie <- sprintf("elke %s minuten", round(x$meetfrequentie, 2))
x$meetfrequentie <- sprintf("elke %s minuten", round(x$meetfrequentie, 2))
}else{
}else{
x <- NULL
x <- NULL
...
...
citizenair/inst/apps/citizenair/page02-exploratory.Rmd
View file @
c291b99e
## Sidebar {.sidebar}
#### Selectiecriteria
```{r}
actionBttn(inputId = "uiInput_selectstation", label = "Vergelijk met ander officieel station", style = "gradient")
```
```{r}
radioButtons(inputId = "uiInput_periode", label = "Vergelijk op basis van",
choices = c("Per minuut" = "minute", "Per uur" = "hour", "Per dag" = "day", "Per maand" = "month"),
selected = "day")
dateRangeInput(inputId = "uiInput_period", label = "Verander de periode", start = Sys.Date()-365, end = Sys.Date())
actionButton(inputId = "uiInput_refresh", label = "Herbereken")
```
## Verken je metingen {.tabset}
## Verken je metingen {.tabset}
### Toon je metingen
### Verken je metingen
Hieronder tonen we een overzicht van jouw meting en de dichtstbijzijnde VMM-meetplaats in
functie van de tijd. Verken je meting hieronder en kijk eens wat er gebeurt als je uitmiddelt per
uur, per dag enz. Als je een goed zicht hebt op je data, ga dan naar de volgende stap.
```{r}
```{r}
x <- dashinput$appdata$fetch_timeseries("1030")
x <- dashinput$appdata$fetch_timeseries("1030")
...
@@ -14,32 +33,57 @@ g <- dyRangeSelector(g, height = 20)
...
@@ -14,32 +33,57 @@ g <- dyRangeSelector(g, height = 20)
g
g
```
```
### Vergelijk met offici
ële metinge
n
### Vergelijk met offici
eel meetstatio
n
### Is mijn meettoestel correct
### Is mijn meettoestel correct
## Inputs {data-width=150}
## Inputs {data-width=150}
### Inputs
###
```{r}
renderValueBox({
userdata <- citizenair_userdata()
stations <- userdata$stations
stations <- subset(stations, id %in% userdata$nearest_station)
if(nrow(stations) > 0){
ui <- valueBox(stations$label, caption = "Vergelijk met officieel meetstation")
}else{
ui <- NULL
}
ui
})
```
Laad een nieuwe file
###
```{r}
```{r}
actionButton(inputId = "uiInput_refresh", label = "Refresh")
renderValueBox({
radioButtons(inputId = "uiInput_periode", label = "Period - shortcuts",
filename <- citizenair_userdata()$name
choices = c("Per seconde" = "Per seconde",
if(length(filename) > 0){
"Per minuut" = "Per minuut",
ui <- valueBox("Uw excel file", caption = citizenair_userdata()$name)
"Per 5 minuten" = "Per 5 minuten",
}else{
"Per uur" = "Per uur",
ui <- NULL
"Per dag" = "Per dag",
}
"Per week" = "Per week"),
ui
selected = "Per minuut"
)
}
)
```
```
###
```{r}
```{r}
materialSwitch(inputId = "ui_events_period_custom", label = "Custom period",
renderUI({
value = FALSE, status = "info")
userdata <- citizenair_userdata()
dateRangeInput(inputId = "ui_events_period", label = "Custom period", start = Sys.Date(), end = Sys.Date()+1)
x <- userdata$data$meta
actionButton(inputId = "ui_events_start", label = "Refresh")
if(is.data.frame(x) && nrow(x) > 0){
choices <- as.list(x$sheet_id)
names(choices) <- x$sheet
ui <- selectInput(inputId = "uiInput_sheet", label = "Selecteer sheet", choices = choices, selected = choices, multiple = TRUE)
}else{
ui <- NULL
}
ui
})
```
```
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment