简体   繁体   English

使用 R 解压缩.tif.gz 文件

[英]Decompress .tif.gz file using R

I got data from Chirps in tif.gz format, I tried R.utils::gunzip to get the maps but I got an error.我从 Chirps 获得了 tif.gz 格式的数据,我尝试R.utils::gunzip来获取地图,但出现错误。

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

data link . 数据链接

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尝试了这些,但没有

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文件:啁啾-v2.0.1981.01.01.tif

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM