0

I'm trying to download a shapefile that comes from the writeOGR function. However it's not working and it can't download the shapefile. Does anyone know how to fix this? I really appreciate! Here comes the server.R:

  output$shapefile <- renderUI({

  if(is.null(input$action))
    return(NULL)
  else
    isolate({ 
    if(is.null(input$checkboxpd))
      return(NULL)
    else
      downloadHandler(
        filename = function() {
          paste("Arvores_indiv_LiDAR", "shp", sep=".")
        },
        content = function() { 

        trees5 <- FindTreesCHM(fchm(), (as.numeric(input$fws)), (as.numeric(input$minht)))
        lots <- SpatialPointsDataFrame(coords = cbind(trees5), data = trees5)
        writeOGR(lots, dsn="Arvores_indiv_LiDAR.shp", layer = "Arvores_indiv_LiDAR", driver = "ESRI Shapefile")
        dev.off

        })    
    })
    })

Thanks a lot! :)

Xiongbing Jin
  • 11,779
  • 3
  • 47
  • 41
  • It's very difficult to debug a non-reproducible example. Please provide a minimum reproducible example preferrably with an open or R built-in dataset – Xiongbing Jin Oct 27 '16 at 14:07
  • Could you email me so I send you the files? iasmimlouriiene@gmail.com – Iasmim Louriene Oct 27 '16 at 19:58
  • Looking at your code more carefully, it appears that the issue is with the `content = function()` line. `downloadHandler` requires that the function takes a `file` argument. So you should change it to `content = function(file)`, and then on the `writeOGR` line, change to `dsn=file`. This should bring you closer to solving the problem. – Xiongbing Jin Oct 27 '16 at 21:05
  • Hey! I tried to run the code again fixing those and still it doesn't work. I appreciate your help anyways! Thank you! – Iasmim Louriene Oct 31 '16 at 18:27

0 Answers0