unzip file error: error 1 in extracting from zip file

I am trying to unzip a shapefile zip file. After download it to my directory, I am getting this error and file is NOT unziped:
Warning message:
In unzip(zipfile = temp, exdir = temp2) : error 1 in extracting from zip file

R code:
dir <- getwd()
zip.combine <- as.character(paste(dir, zip.file, sep = "/"))

download.file("https://github.com/silpai/DC_HarvardX/blob/master/shp/lpr_000a16a_e.zip" , destfile=zip.combine) # Download the shapefile.

zipF<-file.choose() # lets you choose file "lpr_000a16a_e.zip"
outDir<- getwd()
unzip(zipF,exdir=outDir) # unzip your file

Why I am getting this error 1 in extracting from zip file?

read shapefile

can <- st_read("lpr_000b16a_e.shp")

I was able to fix this issue. It was related to the downloading... it did not complete, for some reason, so unzip did not work.

I just replaced the github link to the "http://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/files-fichiers/2016/lpr_000a16a_e.zip"

The issue with your code is that the actual download link for your shp file is: https://github.com/silpai/DC_HarvardX/raw/master/shp/lpr_000a16a_e.zip. If you use it in your code, the right file will be downloaded and you will be able to unzip it. I got the link by right clicking on the "Download" button and then copying the link address.

On a different note, you would greatly benefit from using RStudio projects as well as the here package in your work.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.