rzipwarningstemp

Error 1 extracting ZIP file into temporary folder


The code was developed by eBird and can be found here.

When I run the second set of code, this warning is produced and one cannot continue:

Warning message:
In unzip(tmp_bcr, exdir = tmp_dir) : error 1 in extracting from zip file

Here is the code that produces the error:

# download bcrs
tmp_dir <- normalizePath(tempdir())
tmp_bcr <- file.path(tmp_dir, "bcr.zip")
paste0("https://www.birdscanada.org/research/gislab/download/", 
       "bcr_terrestrial_shape.zip") %>% 
  download.file(destfile = tmp_bcr)
unzip(tmp_bcr, exdir = tmp_dir)

Could the slashes below be the issue when we look at the defined path on my PC?

> tmp_bcr
[1] "C:...\\AppData\\Local\\Temp\\Rtmpm8LNRB/bcr.zip"

Solution

  • Setting list = TRUE I am getting a data.frame with the file names, their length and creation date.
    And no errors extracting the files.

    tmp_dir <- normalizePath(tempdir())
    tmp_bcr <- "~/Temp/bcr_terrestrial_shape.zip"
    unzip(tmp_bcr, list = TRUE)
    #>                                                            Name   Length                Date
    #> 1                  BCR_Terrestrial/BCR_Terrestrial_dissolve.CPG        5 2020-01-17 13:21:00
    #> 2                  BCR_Terrestrial/BCR_Terrestrial_dissolve.dbf     3662 2020-01-17 13:21:00
    #> 3                  BCR_Terrestrial/BCR_Terrestrial_dissolve.prj      167 2020-01-17 13:17:00
    #> 4                  BCR_Terrestrial/BCR_Terrestrial_dissolve.sbn     1068 2020-01-17 13:17:00
    #> 5                  BCR_Terrestrial/BCR_Terrestrial_dissolve.sbx      156 2020-01-17 13:17:00
    #> 6                  BCR_Terrestrial/BCR_Terrestrial_dissolve.shp  7091068 2020-01-17 13:21:00
    #> 7              BCR_Terrestrial/BCR_Terrestrial_dissolve.shp.xml    13760 2020-01-20 15:29:00
    #> 8                  BCR_Terrestrial/BCR_Terrestrial_dissolve.shx      892 2020-01-17 13:21:00
    #> 9                    BCR_Terrestrial/BCR_Terrestrial_master.CPG        5 2020-01-17 13:11:00
    #> 10                   BCR_Terrestrial/BCR_Terrestrial_master.dbf    83192 2020-01-17 13:11:00
    #> 11                   BCR_Terrestrial/BCR_Terrestrial_master.prj      167 2020-01-17 13:11:00
    #> 12                   BCR_Terrestrial/BCR_Terrestrial_master.sbn     3740 2020-01-17 13:11:00
    #> 13                   BCR_Terrestrial/BCR_Terrestrial_master.sbx      252 2020-01-17 13:11:00
    #> 14                   BCR_Terrestrial/BCR_Terrestrial_master.shp 13264916 2020-01-17 13:11:00
    #> 15               BCR_Terrestrial/BCR_Terrestrial_master.shp.xml    15677 2020-01-20 15:29:00
    #> 16                   BCR_Terrestrial/BCR_Terrestrial_master.shx     3084 2020-01-17 13:11:00
    #> 17     BCR_Terrestrial/BCR_Terrestrial_master_International.CPG        5 2020-01-17 13:38:00
    #> 18     BCR_Terrestrial/BCR_Terrestrial_master_International.dbf    11758 2020-01-17 13:38:00
    #> 19     BCR_Terrestrial/BCR_Terrestrial_master_International.prj      167 2020-01-17 13:30:00
    #> 20     BCR_Terrestrial/BCR_Terrestrial_master_International.sbn      820 2020-01-17 13:30:00
    #> 21     BCR_Terrestrial/BCR_Terrestrial_master_International.sbx      156 2020-01-17 13:30:00
    #> 22     BCR_Terrestrial/BCR_Terrestrial_master_International.shp 10235308 2020-01-17 13:30:00
    #> 23 BCR_Terrestrial/BCR_Terrestrial_master_International.shp.xml    13795 2020-01-20 15:29:00
    #> 24     BCR_Terrestrial/BCR_Terrestrial_master_International.shx      644 2020-01-17 13:30:00
    #unzip(tmp_bcr, exdir = tmp_dir)
    

    Created on 2022-11-14 with reprex v2.0.2