Hello @jlacko,
Thank you so much for your explanation.
in fact with it I went to slightly modify the code with
ui<-fluidPage(
dashboardPage(
skin = "red",
dashboardHeader(title = "Soil Map", titleWidth = 350),
dashboardSidebar(width = 350,
sidebarMenu(
menuItem("Soil", tabName = "soil_maps", icon = icon("Map")))),
dashboardBody(
fluidRow(
tabItems(
tabItem(tabName = "soil_maps",
box(title = "Soil map visualization",
width = 3,
status ="danger",
solidHeader = TRUE,
collapsible = TRUE,
radioButtons("soil",
label = "Select the desired soil properties",
choices = list("clay" = "clay",
"sand" = "sand"),
selected = 1),
leafletOutput(outputId = "soil_map", width = "100%", height = 500))))))))
server<-function(input, output) {
clay <- raster("C:/Users/Fiorentini/Desktop/Smart_Farming_App/data/argilla.tif")
sand <- raster("C:/Users/Fiorentini/Desktop/Smart_Farming_App/data/sabbia.tif")
raster <- reactive({
switch(input$soil,
"clay" = clay,
"sand" = sand)
})
output$soil_map <- renderLeaflet({
leaflet() %>% addProviderTiles('Esri.WorldImagery') %>%
addRasterImage(raster())
})
}
shinyApp(ui = ui, server = server)
Also this time, the output is the same of previous
"Warning: Error in addRasterImage: inherits(x, "RasterLayer") is not TRUE"
Do you know a method or shiny widget that i could use to fix this bug?