首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用Python - Sentinel卫星数据解压缩下载的文件

无法使用Python - Sentinel卫星数据解压缩下载的文件
EN

Stack Overflow用户
提问于 2019-10-08 16:00:10
回答 2查看 353关注 0票数 0

我无法解压缩从哥白尼开放存取中心下载的.zip文件。我检索该文件,并尝试使用以下Python脚本将其解压缩:

代码语言:javascript
复制
from sentinelsat.sentinel import SentinelAPI
import zipfile

user = 's5pguest' 
password = 's5pguest' 

api = SentinelAPI(user, password, 'https://s5phub.copernicus.eu/dhus')

api.download("cb078cce-ed6e-46a7-a614-e13830b2a74a")

# The file is succesfully downloaded

zip_ref = zipfile.ZipFile("S5P_NRTI_L2__CO_____20191001T123303_20191001T123803_10188_01_010302_20191001T131513.zip", 'r')
zip_ref.extractall()
zip_ref.close()

该文件已成功下载,但当它尝试解压缩时,我得到:

代码语言:javascript
复制
BadZipFile                                Traceback (most recent call last)
<ipython-input-3-45c213a35459> in <module>
      9 api.download("cb078cce-ed6e-46a7-a614-e13830b2a74a")
     10 
---> 11 zip_ref = zipfile.ZipFile("S5P_NRTI_L2__CO_____20191001T123303_20191001T123803_10188_01_010302_20191001T131513.zip", 'r')
     12 zip_ref.extractall()
     13 zip_ref.close()

~/anaconda3/lib/python3.6/zipfile.py in __init__(self, file, mode, compression, allowZip64)
   1129         try:
   1130             if mode == 'r':
-> 1131                 self._RealGetContents()
   1132             elif mode in ('w', 'x'):
   1133                 # set the modified flag so central directory gets written

~/anaconda3/lib/python3.6/zipfile.py in _RealGetContents(self)
   1196             raise BadZipFile("File is not a zip file")
   1197         if not endrec:
-> 1198             raise BadZipFile("File is not a zip file")
   1199         if self.debug > 1:
   1200             print(endrec)

BadZipFile: File is not a zip file

如果我尝试用unzip从终端解压这个文件,我会得到:

代码语言:javascript
复制
End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of S5P_NRTI_L2__CO_____20191001T123303_20191001T123803_10188_01_010302_20191001T131513.zip or
        S5P_NRTI_L2__CO_____20191001T123303_20191001T123803_10188_01_010302_20191001T131513.zip.zip, and cannot find S5P_NRTI_L2__CO_____20191001T123303_20191001T123803_10188_01_010302_20191001T131513.zip.ZIP, period.

如果我尝试使用7zip,我会得到:

代码语言:javascript
复制
7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=it_IT.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)

Processing archive: S5P_NRTI_L2__CO_____20191004T113803_20191004T114303_10230_01_010302_20191004T122457.zip

Error: Can not open file as archive

该文件似乎已损坏,但如果我尝试下载其他文件,错误仍然存在。我还试着把名字改成一个更简单的名字,比如"doc.zip",但没有成功。我被困住了,有什么好主意吗?

我正在学习本教程https://github.com/acgeospatial/Satellite_Imagery_Python/blob/master/SentinelSat_Demo.ipynb

EN

回答 2

Stack Overflow用户

发布于 2019-10-08 16:17:51

我想你的文件可能不是zip文件。转到该文件属性并检查其是否为.zip格式。

另外,我想提一下,我无法打开您提到的存储库。

如果你在谷歌上搜索7zip错误:

票数 0
EN

Stack Overflow用户

发布于 2019-10-08 17:28:35

有一个错误:https://github.com/sentinelsat/sentinelsat/issues/270文件的.zip扩展名不正确。如果我手动将扩展名从.zip更改为.nc,并尝试使用查看器脚本打开它,则可以正常工作。我想知道我链接的教程是如何工作的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58282319

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档