addRasterImage未在传单闪亮应用程序上渲染

addRasterImage未在传单闪亮应用程序上渲染,r,shiny,mapping,leaflet,r-leaflet,R,Shiny,Mapping,Leaflet,R Leaflet,因此,我尝试动态显示我以前计算过的一些光栅层。我需要更新标记和显示图像上显示的值。 它可以很好地处理标记,但似乎对addRasterImage命令没有任何作用。有什么帮助吗?代码: library(shiny) library(leaflet) library(RColorBrewer) #### Mapa en shiny #### ui <- bootstrapPage( tags$style(type = "text/css", "html, body {width:100%;

因此,我尝试动态显示我以前计算过的一些光栅层。我需要更新标记和显示图像上显示的值。 它可以很好地处理标记,但似乎对addRasterImage命令没有任何作用。有什么帮助吗?代码:

library(shiny)
library(leaflet)
library(RColorBrewer)

#### Mapa en shiny ####
ui <- bootstrapPage(
  tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
  leafletOutput("map", width = "100%", height = "100%"),
  absolutePanel(top = 10, right = 10,
                sliderInput("range", "Fecha", 1, length(arch),
                            value = 1, step = 1
                )
  )
)

server <- function(input, output, session) {

  # Reactive expression for the data subsetted to what the user selected
  # filteredData <- reactive({
  #   a[[input$range]]
  # })

  int.pred<-cropinterp@data@values[!is.na(cropinterp@data@values)]
  pal<-colorNumeric("RdBu", int.pred)
  pal2<- pal<-colorNumeric("Spectral", (int.pred))

  neess<- seq(1,1000,1)
  qpal <- colorBin(terrain.colors(4), domain=neess, bins=c(1,10,100,1000,Inf))

  output$map <- renderLeaflet({
    # Use leaflet() here, and only include aspects of the map that
    # won't need to change dynamically (at least, not unless the
    # entire map is being torn down and recreated).
    leaflet() %>% 
      addTiles(group="OSM (default)") %>%
      setView(lng=-3.77 , lat =40.36, zoom=6) %>%
      addMeasure()%>%
      addRasterImage(rr, colors="Spectral", opacity = 0.7, group ="Krige de Precios") %>%
      addRasterImage(cropinterp, colors="Spectral", opacity = 0.7, group = "Spline de Precios") %>%
      addPolylines(data = cropcont, fillOpacity=0.5, fillColor = "transparent",opacity = 0.7,weight = 2, group = "Contorno Precios") %>%
      addLayersControl(
        baseGroups = c("OSM (default)"),
        overlayGroups = c("Contorno Precios", "Spline de Precios", "Krige de Precios","Spline Madrid"),
        options = layersControlOptions(collapsed = FALSE),
        position="topleft") %>%
      addLegend("bottomright", pal=pal2, values=int.pred, title = "Precio", opacity = 1)%>%
      addLegend(pal = qpal, values = neess, opacity = 1, position="bottomleft")

  })
  # Incremental changes to the map (in this case, replacing the
  # circles when a new color is chosen) should be performed in
  # an observer. Each independent set of things that can change
  # should be managed in its own observer.
  observeEvent(input$range, {
    nn<- input$range
      leafletProxy("map", session)%>%
      clearMarkers()%>%
      clearMarkerClusters()%>%
      addCircleMarkers(lat = timeline$Latitud, lng = timeline$Longitud..WGS84., fillColor = pal,
                       label = paste(as.character(timeline$Rótulo), timeline[,nn+9]),
                       labelOptions = labelOptions(opacity = 0.9,noHide = T), 
                      clusterOptions = markerClusterOptions(), group = "OSM (default)")
  })

  observe({
    na<- input$range
    leafletProxy("map", session)%>%
      addRasterImage(a[[na]], opacity = 0.7)
  })
}

shinyApp(ui, server)
库(闪亮)
图书馆(单张)
图书馆(RColorBrewer)
####马帕恩闪亮####
ui问题已解决:

经过大量的挖掘,我找到了这个问题的答案

问题是光栅图像是在瓷砖下面渲染的(不知道为什么会发生这种情况,但这是一个真正的问题)。在链接问题上提供的答案上,用户通过移除互动程序并在每次输入更改时动态添加互动程序来解决该问题:

tiles <- c("Hydda.Base",
           "Hydda.Full",
           "Esri.WorldImagery",
           "Esri.WorldTopoMap")

  observe({
    filtdata <- filteredData()
    selectedTiles <- input$tiles
    leafletProxy("map", session)%>%
      clearTiles() %>%
      addProviderTiles(selectedTiles, providerTileOptions(zIndex=-10, continuousWorld=FALSE), group="base")%>%
      clearImages() %>%
      addRasterImage(filtdata, colors="Spectral", project=FALSE, opacity = 0.7, group = "Spline Madrid")
  })
tiles%
clearImages()%>%
addRasterImage(filtdata,colors=“Spectral”,project=FALSE,opacity=0.7,group=“Spline”)
})
tiles <- c("Hydda.Base",
           "Hydda.Full",
           "Esri.WorldImagery",
           "Esri.WorldTopoMap")

  observe({
    filtdata <- filteredData()
    selectedTiles <- input$tiles
    leafletProxy("map", session)%>%
      clearTiles() %>%
      addProviderTiles(selectedTiles, providerTileOptions(zIndex=-10, continuousWorld=FALSE), group="base")%>%
      clearImages() %>%
      addRasterImage(filtdata, colors="Spectral", project=FALSE, opacity = 0.7, group = "Spline Madrid")
  })