Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including
Stack Overflow
, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this community
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I downloaded the
AWS Earth search notebook
from the intake-stac examples and whithout changing anything. Just run the cells...
But I've got everytime the error:
KeyError: 'open_stac_item_collection'
Here is my code:
%matplotlib inline
import intake
import satsearch
bbox = [35.48, -3.24, 35.58, -3.14] # (min lon, min lat, max lon, max lat)
dates = '2020-07-01/2020-08-15'
URL='https://earth-search.aws.element84.com/v0'
results = satsearch.Search.search(url=URL,
collections=['sentinel-s2-l2a-cogs'], # note collection='sentinel-s2-l2a-cogs' doesn't work
datetime=dates,
bbox=bbox,
sort=['<datetime'])
items = results.items()
catalog = intake.open_stac_item_collection(items)
This is the result/error:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/opt/anaconda3/envs/openspacedata_app/lib/python3.7/site-packages/intake/__init__.py in __getattr__(attr)
60 try:
---> 61 return gl[attr]
62 except KeyError:
KeyError: 'open_stac_item_collection'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
<ipython-input-29-45f007afa1be> in <module>
----> 1 catalog = intake.open_stac_item_collection(items)
~/opt/anaconda3/envs/openspacedata_app/lib/python3.7/site-packages/intake/__init__.py in __getattr__(attr)
61 return gl[attr]
62 except KeyError:
---> 63 raise AttributeError(attr)
AttributeError: open_stac_item_collection
Update 1
After the solution of Kadir and replace intake_stac.catalog.StacItemCollection
with intake.open_stac_item_collection
, I've got the following error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-61-0321aa237297> in <module>
----> 1 catalog = intake_stac.catalog.StacItemCollection(items)
~/opt/anaconda3/envs/openspacedata_app/lib/python3.7/site-packages/intake_stac/catalog.py in __init__(self, stac_obj, **kwargs)
61 self._stac_obj = self._stac_cls.from_file(stac_obj)
62 else:
---> 63 raise ValueError('Expected %s instance, got: %s' % (self._stac_cls, type(stac_obj)))
65 metadata = self._get_metadata(**kwargs.pop('metadata', {}))
ValueError: Expected <class 'pystac.catalog.Catalog'> instance, got: <class 'satstac.itemcollection.ItemCollection'>
Update 2
Now this works. But then, I'll get an error on the next line:
item = catalog['S2A_36MYB_20200804_0_L2A']
Full error:
KeyError Traceback (most recent call last)
<ipython-input-75-60497ae0cb6f> in <module>
----> 1 item = catalog['S2A_36MYB_20200804_0_L2A']
~/opt/anaconda3/envs/openspacedata_app/lib/python3.7/site-packages/intake/catalog/base.py in __getitem__(self, key)
415 out = self[part]
416 return out()
--> 417 raise KeyError(key)
419 def discover(self):
KeyError: 'S2A_36MYB_20200804_0_L2A'
It must be removed from the package. The error says: "there is no such a method in the package".
Install intake-stac
.
pip install intake-stac
Then, you can use intake_stac.catalog.StacItemCollection
instead of intake.open_stac_item_collection
(Reference).
import intake_stac
# ...
catalog = intake_stac.catalog.StacItemCollection(items)
Result:
<class 'satstac.itemcollection.ItemCollection'>:
args:
stac_obj: !!python/object:satstac.itemcollection.ItemCollection
_collections:
- &id001 !!python/object:satstac.collection.Collection
_data:
description: Sentinel-2a and Sentinel-2b imagery, processed to Level 2A
(Surface Reflectance) and converted to Cloud-Optimized GeoTIFFs
extent:
spatial:
bbox:
- - -180
- -90
UPDATE:
The following line gives some results. Please try that:
catalog = intake_stac.catalog.Catalog(items)
null:
args:
entries: !!python/object:satstac.itemcollection.ItemCollection
_collections:
- &id001 !!python/object:satstac.collection.Collection
_data:
description: Sentinel-2a and Sentinel-2b imagery, processed to Level 2A
(Surface Reflectance) and converted to Cloud-Optimized GeoTIFFs
extent:
spatial:
bbox:
- - -180
- -90
–
–
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.