首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SentinelAPIError。HTTP状态200 OK: API响应无效。JSON解码失败

SentinelAPIError。HTTP状态200 OK: API响应无效。JSON解码失败
EN

Stack Overflow用户
提问于 2020-12-29 19:16:23
回答 2查看 319关注 0票数 1

我一直在尝试使用python通过geojson API获取数据,但一直无法通过sentinel2格式获取数据。它一直抛出"SentinelAPIError: HTTP status 200 OK: API response It . JSON解码失败。“

我彻底地遵循了文档,但我仍然得到相同的错误。我可以获取Point数据,但无法获取geojson数据。

我将感谢你在这方面的帮助。以下是代码的片段。“

代码语言:javascript
复制
    if self.boundary.endswith('.geojson'):
        
        
        footprint = geojson_to_wkt(read_geojson(self.boundary))

        
        products = api.query(footprint,
                             
                     date=(self.start_date,self.end_date),

                     platformname = 'Sentinel-2',

                     cloud_cover= (0,self.cloud_cover))
        

        products_gdf = api.to_geodataframe(products)

这就是错误。

代码语言:javascript
复制
/usr/local/lib/python3.6/dist-packages/sentinelsat/sentinel.py in _load_subquery(self, query, order_by, limit, offset)
    394             json_feed = response.json()["feed"]
--> 395             if json_feed["opensearch:totalResults"] is None:
    396                 # We are using some unintended behavior of the server that a null is

KeyError: 'opensearch:totalResults'
During handling of the above exception, another exception occurred:

SentinelAPIError                          Traceback (most recent call last)
4 fr
/usr/local/lib/python3.6/dist-packages/sentinelsat/sentinel.py in _load_subquery(self, query, order_by, limit, offset)
    401             total_results = int(json_feed["opensearch:totalResults"])
    402         except (ValueError, KeyError):
--> 403             raise SentinelAPIError("API response not valid. JSON decoding failed.", response)
    404 
    405         products = json_feed.get("entry", [])

SentinelAPIError: HTTP status 200 OK: API response not valid. JSON decoding failed.

谢谢。

EN

回答 2

Stack Overflow用户

发布于 2020-12-30 23:31:38

your.geojson文件似乎无法解码。首先检查已创建的文件的编码语言。如果这还不管用,

检查您的.geojson是否与以下格式类似:

{“类型”:"FeatureCollection",“要素”:[{“类型”:“要素”,“属性”:{},“几何”:{“类型”:“多边形”,“坐标”:[[ 23.642578125,37.93553306183642,23.8018798828125,37.93553306183642,23.8018798828125,38.026458711461245,23.642578125,38.026458711461245,23.642578125,37.93553306183642 ]}

你可以在this页面中快速生成一个.geojson文件。

票数 0
EN

Stack Overflow用户

发布于 2021-01-21 16:03:58

事实证明,我的问题是我没有使用为API创建的正确变量。当它应该是self.cloudcoverpercentage的时候,我编写了self.cloud_cover。我在文档中跳过了。

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

https://stackoverflow.com/questions/65491266

复制
相关文章

相似问题

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