Python API的校验和无效.使用geoandas和Geojson



我正在寻找一种自动下载卫星图像以创建数据库的方法。我弄清楚了这个问题,并从sentinelsat API开始,由于它的特殊性,没有太多关于它的信息。我的步骤是:我使用这个网站https://geojson.io来选择一个多边形,并下载一个geojson文件。我将其添加到地理数据框架(geopandas)中显然没有任何理由。随后,我使用多边形将其添加到查询(api.query)中,获得产品,循环使用它们,检查它们是否在线并尝试下载它们,但我得到以下错误(对于所有在线的):

0  POLYGON ((-53.27854 -24.97081, -53.30223 -24.9...
Querying products: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 362/362 [00:06<00:00, 42.74product/s]
            title  ...                                           geometry
f8184c3e-6760-461c-af2b-5cb3183f864d  S2A_MSIL2A_20211126T134211_N0301_R124_T22JBT_2...  ...  MULTIPOLYGON (((-52.89090 -25.39290, -52.87585...
f2a70ef8-b6ba-4612-8f3a-b4ec4d60ebc3  S2A_MSIL2A_20211126T134211_N0301_R124_T21JZN_2...  ...  MULTIPOLYGON (((-54.01898 -25.37484, -52.92975...
47d725db-7753-4407-9d67-90ec12053fac  S2B_MSIL2A_20211121T134209_N0301_R124_T21JZN_2...  ...  MULTIPOLYGON (((-54.01898 -25.37484, -52.92975...
b3a96909-c276-498e-ad77-4fc89675fa19  S2B_MSIL2A_20211121T134209_N0301_R124_T22JBT_2...  ...  MULTIPOLYGON (((-52.89090 -25.39290, -52.87585...
6ddcee95-edc5-4a33-b5a3-820dbbee3431  S2A_MSIL2A_20211116T134211_N0301_R124_T22JBT_2...  ...  MULTIPOLYGON (((-52.89090 -25.39290, -52.87585...
...                                                                                 ...  ...                                                ...
b5b00501-8c99-4a89-87c1-dc99c421cbd7  S2B_MSIL2A_20190615T134219_N0212_R124_T21JZN_2...  ...  MULTIPOLYGON (((-54.01898 -25.37484, -52.92975...
1cb316a6-025a-40e6-a051-6b3eb13a91d4  S2A_MSIL2A_20190610T134211_N0212_R124_T22JBT_2...  ...  MULTIPOLYGON (((-52.89090 -25.39290, -52.87585...
3b6181b8-459c-4a04-aa9e-ad8e1329a5e3  S2A_MSIL2A_20190610T134211_N0212_R124_T21JZN_2...  ...  MULTIPOLYGON (((-54.01898 -25.37484, -52.92975...
f8dddff3-e1da-4d7c-ae85-aa8aced8e337  S2B_MSIL2A_20190605T134219_N0212_R124_T21JZN_2...  ...  MULTIPOLYGON (((-54.01898 -25.37484, -52.92975...
d75470e8-bd80-42d0-9129-41db94aa292f  S2B_MSIL2A_20190605T134219_N0212_R124_T22JBT_2...  ...  MULTIPOLYGON (((-52.89090 -25.39290, -52.87585...
[362 rows x 41 columns]
Product ' 0 '
Product ' 1 '
Product: f2a70ef8-b6ba-4612-8f3a-b4ec4d60ebc3  is online.
Downloading S2A_MSIL2A_20211126T134211_N0301_R124_T21JZN_20211126T160417.zip:   0%|                                                                                                                 | 0.00/1.19G [00:00<?, ?B/s]
Traceback (most recent call last):
File "c:UsersphzozPythonProjectsSentinelmain.py", line 32, in <module>
api.download(product, directory_path="Data", checksum=True)
File "C:Usersphzozanaconda3envssentinellibsite-packagessentinelsatsentinel.py", line 590, in download
return downloader.download(id, directory_path)
File "C:Usersphzozanaconda3envssentinellibsite-packagessentinelsatdownload.py", line 150, in download
self._download_common(product_info, path, stop_event)
File "C:Usersphzozanaconda3envssentinellibsite-packagessentinelsatdownload.py", line 229, in _download_common
raise InvalidChecksumError("File corrupt: checksums do not match")
sentinelsat.exceptions.InvalidChecksumError: File corrupt: checksums do not match

下面是代码摘要:

api = SentinelAPI(user, password, "https://scihub.copernicus.eu/dhus")
gjPath = "Data/files_geojson/map.geojson"
gdf = geopandas.read_file(gjPath)
print(gdf)
footprint = None
for i in gdf["geometry"]:
footprint = i
#("20190601", "20190626")
products = api.query(footprint, date=("20190601", "20211201"), platformname="Sentinel-2", processinglevel="Level-2A")
productsGDF = api.to_geodataframe(products)
print(productsGDF)
for i, product in enumerate(products):
print("Product '", i, "'")
if api.is_online(product):
print("Product:", str(product), " is online.")
api.download(product, directory_path="Data", checksum=True)

我不明白我是否需要引导API来发出请求或其他东西,因为产品是真正可用的,但文档似乎说你可以去做,加上我真的不知道校验和是什么意思,显然是某种传输验证。

显然问题解决了,几天后继续使用不同的json文件,(没有做geodataframe部分)和下载与校验和下载正常,我确实不得不等待几天后的第一次初始更改(因为之后它仍然下载在缓慢的速度,只是与校验和启用),我想这是一个问题的方式我使用数据api,加上一些连接问题。

最新更新