1

I would like to add a line after the transformation of my shapefile in order to save it in a temporary file.

uploadShpfile <- reactive({
    if (!is.null(input$shp)) {
      inFile <- input$shp
      inFolder <- substr(inFile$datapath, 1, nchar(inFile$datapath) - 5)
      unzip(inFile$datapath, exdir = inFolder)
      shpDF <- input$shp
      pwd <- getwd()
      updir <- dirname(shpDF$datapath[1])
      setwd(updir)
      for (i in 1:nrow(shpDF)) {
        file.rename(shpDF$datapath[i], shpDF$name[i])
      }
      shpName <- shpDF$name[grep(x = shpDF$name, pattern = "*.shp")]
      shpPath <- paste(updir, shpName, sep = "/")
      setwd(pwd)
      shpFile <- readOGR(shpPath)
      shpFile <- spTransform(shpFile,CRS("+proj=longlat +datum=WGS84"))

Any ideas ?

1

Assuming you want to save to temporary shapefile the last line could be something like: shapefile(shpFile, tempfile(pattern = "", fileext = ".shp"))

  • Hello Monchill, thank you for the reply. "shapefile" is not found as a function. What can I write instead? – Grits Jun 17 at 5:21
  • 1
    Okay I found the problem. I didn't had the package "raster". Thank you @Monchill. You were very helpful :) – Grits Jun 17 at 6:43
  • 1
    Yes, sorry, I should have included the required package list. Good that you found the solution! – Momchill Jun 19 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.