adokter / bioRad

R package for analysis and visualisation of biological signals in weather radar data
http://adokter.github.io/bioRad
Other
29 stars 16 forks source link

dynamic visualisation of maps with leaflet and shiny #327

Open adokter opened 4 years ago

adokter commented 4 years ago

Suggestion to introduce new ppi method mapview(), which mirrors map() but allows users to pan and zoom. This is quite easily implemented with leaflet and shiny

Here an example to plot a ppi object (named ppi_int) which plots

# plot data using leaflet:
library(viridis)
library(leaflet)
library(shiny)
library(htmltools)
load("~/git/mosaic_aws/basemap.RData")
r <- raster(ppi_int$data)
pal <- colorNumeric("viridis",c(0,7),
                    na.color = "transparent")
previewColors(pal,seq(0,7))
leaflet() %>%
  # Base groups
  addTiles(group = "OSM (default)") %>%
  addProviderTiles(providers$Stamen.Toner, group = "Toner") %>%
  addProviderTiles(providers$Stamen.TonerLite, group = "Toner Lite") %>%
  addRasterImage(r, colors = pal, opacity = 0.8, group="VID") %>%
  addTerminator(time=grid[i], group="daylight") %>%
  addLayersControl(
    baseGroups = c("OSM (default)", "Toner", "Toner Lite"),
    overlayGroups = c("VID","daylight","radars", "legend"),
    options = layersControlOptions(collapsed = FALSE)) %>%
  hideGroup("daylight") %>%
  hideGroup("radars") %>%
  addMarkers(~lon, ~lat, data=radarInfo, popup = ~paste(sep= "<br/>", paste("radar: ",radar), paste("height: ",height), paste("antenna: ",antenna)), group="radars") %>%
  addLegend(pal = pal, values = c(0,7), title = "log(VID)", group="legend")
adokter commented 4 years ago

Rplot00 Rplot

bart1 commented 4 years ago

A quick note here, I developed starsTileServer to do this (https://gitlab.com/bartk/starsTileServer/). It might be slightly more complex but can produce more scalable results the addRasterImage functions