Catalog search don't work
sebfoe opened this issue · 1 comments
sebfoe commented
Hello all,
I want to load all Sentinel-2 products for January 2019 in an area of interest via Planetarys Computer JupyterLab via:
from pystac_client import Client
import planetary_computer
catalog = Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace)
x_min = 5.7
x_max = 16
y_min = 47.025
y_max = 50.812
area_of_interest = {
"type": "Polygon",
"coordinates": [
[
[x_max, y_min],
[x_min, y_min],
[x_min, y_max],
[x_max, y_max],
[x_max, y_min],
]
],}
time_of_interest = "2019-01"
search = catalog.search(collections=["sentinel-2-l2a"],
intersects=area_of_interest,
datetime=time_of_interest,
#query={"eo:cloud_cover": {"lt": 100}},
)
items = search.item_collection()
Trying this will give me an APIError:
APIError: The request exceeded the maximum allowed time, please try again. If the issue persists, please contact planetarycomputer@microsoft.com.
Debug information for support: 0aSG1ZAAAAAC5yLOMbWyXS4Mq4pR59StDQU1TMDRFREdFMTgwNgA5MjdhYmZhNi0xOWY2LTRhZjEtYTA5ZC1jOTU5ZDlhMWU2NDQ=
Does anyone know what went wrong?
Is this a known issue?
Thank you very much for your support!
Best,
Sebastian
Whole Error:
---------------------------------------------------------------------------
APIError Traceback (most recent call last)
Cell In[6], line 31
25 time_of_interest = "2019-01"
26 search = catalog.search(collections=["sentinel-2-l2a"],
27 intersects=area_of_interest,
28 datetime=time_of_interest,
29 #query={"eo:cloud_cover": {"lt": 100}},
30 )
---> 31 items = search.item_collection()
File /srv/conda/envs/notebook/lib/python3.11/site-packages/pystac_client/item_search.py:756, in ItemSearch.item_collection(self)
748 """
749 Get the matching items as a :py:class:`pystac.ItemCollection`.
750
751 Return:
752 ItemCollection: The item collection
753 """
754 # Bypass the cache here, so that we can pass __preserve_dict__
755 # without mutating what's in the cache.
--> 756 feature_collection = self.item_collection_as_dict.__wrapped__(self)
757 # already signed in item_collection_as_dict
758 return ItemCollection.from_dict(
759 feature_collection, preserve_dict=False, root=self.client
760 )
File /srv/conda/envs/notebook/lib/python3.11/site-packages/pystac_client/item_search.py:777, in ItemSearch.item_collection_as_dict(self)
764 """
765 Get the matching items as an item-collection-like dict.
766
(...)
774 Dict : A GeoJSON FeatureCollection
775 """
776 features = []
--> 777 for page in self.pages_as_dicts():
778 for feature in page["features"]:
779 features.append(feature)
File /srv/conda/envs/notebook/lib/python3.11/site-packages/pystac_client/item_search.py:727, in ItemSearch.pages_as_dicts(self)
725 if isinstance(self._stac_io, StacApiIO):
726 num_items = 0
--> 727 for page in self._stac_io.get_pages(
728 self.url, self.method, self.get_parameters()
729 ):
730 call_modifier(self.modifier, page)
731 features = page.get("features", [])
File /srv/conda/envs/notebook/lib/python3.11/site-packages/pystac_client/stac_api_io.py:304, in StacApiIO.get_pages(self, url, method, parameters)
302 while next_link:
303 link = Link.from_dict(next_link)
--> 304 page = self.read_json(link, parameters=parameters)
305 if not (page.get("features") or page.get("collections")):
306 return None
File /srv/conda/envs/notebook/lib/python3.11/site-packages/pystac/stac_io.py:202, in StacIO.read_json(self, source, *args, **kwargs)
185 def read_json(self, source: HREF, *args: Any, **kwargs: Any) -> Dict[str, Any]:
186 """Read a dict from the given source.
187
188 See :func:`StacIO.read_text <pystac.StacIO.read_text>` for usage of
(...)
200 given source.
201 """
--> 202 txt = self.read_text(source, *args, **kwargs)
203 return self.json_loads(txt)
File /srv/conda/envs/notebook/lib/python3.11/site-packages/pystac_client/stac_api_io.py:161, in StacApiIO.read_text(self, source, *args, **kwargs)
157 else:
158 # parameters are already in the link href
159 parameters = {}
--> 161 return self.request(
162 href, method=method, headers=headers, parameters=parameters
163 )
164 else: # str or something that can be str'ed
165 href = str(source)
File /srv/conda/envs/notebook/lib/python3.11/site-packages/pystac_client/stac_api_io.py:216, in StacApiIO.request(self, href, method, headers, parameters)
214 raise APIError(str(err))
215 if resp.status_code != 200:
--> 216 raise APIError.from_response(resp)
217 try:
218 return resp.content.decode("utf-8")
APIError: The request exceeded the maximum allowed time, please try again. If the issue persists, please contact planetarycomputer@microsoft.com.
Debug information for support: 0aSG1ZAAAAAC5yLOMbWyXS4Mq4pR59StDQU1TMDRFREdFMTgwNgA5MjdhYmZhNi0xOWY2LTRhZjEtYTA5ZC1jOTU5ZDlhMWU2NDQ=
TomAugspurger commented
Thanks for the report. We're looking into this and will post updates in microsoft/PlanetaryComputer#240.