Hi! Im trying to download a raster as geotif. The reactive function works fine to display using spplot the selected raster, but I
m not able to download any file. Im very new in R and shiny. I
ll really appreciate any suggestions. BFT_PR, YFT_PR and FAI are stored raster files.
cheers
Alberto Abad
server <- function(input, output) {
output$range <- renderText({paste("Forecast from", timestart, "to", timeend)})
# Reactive value for selected dataset ----
output$model <- renderPlot({
mapInput <- reactive({
switch(input$model,
"Bluefin tuna" = BFT_PR,
"Yellowfin tuna" = YFT_PR,
"Fishing Aptitude Index"=FAI)})
spplot(mapInput())
})
# Downloadable map shapefile ----
output$downloadData <- downloadHandler(
filename = function() {
paste(input$model, ".tif", sep = "")
},
content = function(file) {
writeRaster(mapInput(), file, format="GTiff", overwrite=TRUE)
}
)
}