creating a dynamic raster in a shinyApp

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)
}

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.