Skip to content

Commit

Permalink
fix up tutorial code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyhq committed Sep 30, 2020
1 parent a43a0cf commit d3e0327
Showing 1 changed file with 43 additions and 15 deletions.
58 changes: 43 additions & 15 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------
Expand All @@ -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`
-------------------------

Expand All @@ -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=['<datetime'], #earliest scene first
property=["landsat:tier=T1"])
url=URL,
collections=['landsat-8-l1-c1'],
bbox=[43.16, -11.32, 43.54, -11.96]
)
items = results.items()
display(items)
items
In the code section above, `items` is a `satstac.ItemsCollection` object.
Intake-stac can turn this object into an Intake catalog:
Expand Down

0 comments on commit d3e0327

Please sign in to comment.