Reputation: 109
I got data from Chirps in tif.gz format, I tried R.utils::gunzip
to get the maps but I got an error.
file<-"./chirps-v2.0.1981.01.01.tif.gz"
R.utils::gunzip(file,remove=F)
Error:
Error in readBin(inn, what = raw(0L), size = 1L, n = BFR.SIZE) :
error reading from the connection
In addition: Warning message:
In readBin(inn, what = raw(0L), size = 1L, n = BFR.SIZE) :
invalid or incomplete compressed data
If there is a better alternative to unzip these files it will be a great solution. Thank you in advance.
I tried these but it didn't work R: read GeoTiff from gz file with a connection and raster package Decompress gz file using R
Upvotes: 1
Views: 1668
Reputation: 173813
The following works for me:
url <- paste0("https://data.chc.ucsb.edu/products/CHIRPS-2.0/",
"global_daily/tifs/p05/1981/chirps-v2.0.1981.01.01.tif.gz")
download.file(url, "chirps-v2.0.1981.01.01.tif.gz")
R.utils::gunzip("chirps-v2.0.1981.01.01.tif.gz", remove = FALSE)
File: chirps-v2.0.1981.01.01.tif
Upvotes: 3