From d3e0327b88af537e6056f7cc0af068218d9f953a Mon Sep 17 00:00:00 2001 From: Scott Henderson Date: Wed, 30 Sep 2020 15:19:39 -0700 Subject: [PATCH] fix up tutorial code blocks --- docs/source/tutorial.rst | 58 +++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/docs/source/tutorial.rst b/docs/source/tutorial.rst index 21d1fdc..91d33c0 100644 --- a/docs/source/tutorial.rst +++ b/docs/source/tutorial.rst @@ -60,7 +60,7 @@ STAC objects. You can also pass ``satstac`` objects (e.g. import satstac col = satstac.Collection.open(f'{root_url}/catalog.json') - collection_cat = intake.open_stac_collection(url) + collection_cat = intake.open_stac_collection(col) Using the catalog ----------------- @@ -70,30 +70,57 @@ contents: .. ipython:: python - catalog = catalog['hurricane-harvey']['hurricane-harvey-0831'] - for id, entry in catalog.items(): - display(entry) + print(list(catalog)) + cat = catalog['hurricane-harvey'] + + print(list(cat)) + subcat = cat['hurricane-harvey-0831'] + + items = list(subcat) + print(items) + + + +When you locate an item of interest, you have access to metadata and methods to load assets into Python objects + +.. ipython:: python + + item = subcat['Houston-East-20170831-103f-100d-0f4f-RGB'] + print(type(item)) + print(item.metadata) + + assets = list(item) + print(assets) + + asset = item['thumbnail'] + print(type(asset)) + print(asset.urlpath) + If the catalog has too many entries to comfortably print all at once, you can narrow it by searching for a term (e.g. 'thumbnail'): .. ipython:: python - for id, entry in catalog.search('thumbnail').items(): - display(entry) + for id, entry in subcat.search('thumbnail').items(): + print(id) + + asset = subcat['Houston-East-20170831-103f-100d-0f4f-RGB.thumbnail'] + print(asset.urlpath) + Loading a dataset ----------------- Once you have identified a dataset, you can load it into a ``xarray.DataArray`` -using Intake's `to_dask()` method: +using Intake's `to_dask()` method. This reads only metadata, and streams values over the network when required by computations or visualizations: .. ipython:: python - entry = catalog['thumbnail'] - da = entry.to_dask() + da = asset.to_dask() display(da) + Working with `sat-search` ------------------------- @@ -104,14 +131,15 @@ using `sat-search`: .. ipython:: python import satsearch - + print(satsearch.__version__) + URL='https://earth-search.aws.element84.com/v0' results = satsearch.Search.search( - collection='landsat-8-l1', - bbox=[43.16, -11.32, 43.54, -11.96], - sort=['