Hi there,
i am new in this community and trying my first shiny app. I have a harmonic fitting over a time series of rasters that I want to visualize dynamically (e.g. with a slider). That for I have a function, that returns the raster at the desired time, depending on the time (input from the slider). My approach so far is below, but whatever I do, the raster does not show up in the App.
thanks for your help,
cheers,
David
{
ui <- fluidPage(
sliderInput(inputId = "slider",
label = "values",
min = 0,
max = 1,
value = 0,
step = 0.01),
leafletOutput("my_leaf")
)
server <- function(input, output, session){
## create static element
output$my_leaf <- renderLeaflet({
leaflet() %>%
addTiles() %>%
setView(lat = (bbox(rec)[[4]]+bbox(rec)[[2]])/2, lng = (bbox(rec)[[1]]+bbox(rec)[[3]])/2, zoom = 12)
})
## get the desired Raster. First three inputs are local variables.
r_NDVI_temp<- reactive({
computeVI(r, harm_deg,time_range[[1]], input$slider)
})
observe({
leafletProxy("raster_map") %>%
clearImages() %>%
addTiles() %>%
addRasterImage(r_NDVI_temp(), opacity = 0.5)# %>%
#addLegend(pal = pal, values = values(r),
# title = "Surface temp")
})
}
shinyApp(ui, server)
}