如何解决哨兵API错误 HTTP 状态 200 OK:API 响应无效 JSON 解码失败
我一直在尝试使用 python 通过 sentinel2 API 获取数据,但我一直无法通过 geojson 格式获取数据。它不断抛出一个 “SentinelAPIError:HTTP 状态 200 OK:API 响应无效。JSON 解码失败。”
我彻底遵循了文档,但我一直遇到同样的错误。我可以获取 Point 数据,但无法获取 geojson 数据。
感谢您对此的帮助。这是代码的片段。 "
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)
”
这是错误。
/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,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.
谢谢。
解决方法
你的.geojson文件好像无法解码。 首先检查已创建文件的编码 - 语言。如果这没有帮助,
检查您的 .geojson 是否类似于以下格式:
{ "type": "FeatureCollection",“特征”: [ { "type": "功能",“特性”: {}, “几何学”: { "type": "多边形",“坐标”:[ [ [ 23.642578125, 37.93553306183642 ],[ 23.8018798828125,37.93553306183642 ],38.026458711461245 ],[ 23.642578125, 38.026458711461245 ],[ 23.642578125, 37.93553306183642 ] ] ] } } ] }
您可以在 this 页面快速生成 .geojson 文件。
,原来我的问题是我没有使用为 API 创建的正确变量。我写了 self.cloud_cover
的时候应该是 self.cloudcoverpercentage
。我在文档中跳过了。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。