Не удается распаковать загруженный файл с данными спутника Python - Sentinel - PullRequest
0 голосов
/ 08 октября 2019

Я не могу разархивировать ZIP-файл, загруженный с Copernicus Open Access Hub. Я извлекаю файл и пытаюсь разархивировать его, используя следующий скрипт Python:

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()

Файл успешно загружен, но когда он пытается разархивировать, я получаю:

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 я получаю:

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, я получаю:

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

Ответы [ 2 ]

0 голосов
/ 08 октября 2019

Есть ошибка: https://github.com/sentinelsat/sentinelsat/issues/270 Файл имеет неправильное расширение .zip. Если я вручную изменяю расширение с .zip на .nc и пытаюсь открыть его с помощью сценария просмотра, это работает. Мне интересно, как учебник, на который я ссылаюсь, может работать.

0 голосов
/ 08 октября 2019

Я думаю, что ваш файл, возможно, не является zip-файлом. Перейдите к свойствам этого файла и проверьте его формат .zip или нет.

Running proof

А также я хотел бы отметить, что яне удалось открыть упомянутое вами хранилище.

Если вы гуглите ошибку 7zip : Google error search

...