<jupyter_start><jupyter_text>Intake-STAC + Planetscope================In this notebook, we'll take a look at some of the functionality in Intake-STAC by exploring STAC catalogs such as the open-access [Planet Disaster data catalog](https://planet.stac.cloud/?t=catalogs) hosted at https://raw.githubusercontent.com/cholmes/sample-stac/master/stac/catalog.json.STAC metadata is organized into a hierarchy of **Catalogs, Collections, and Items**. Items ultimately hold *Assets* which are data files such as satellite raster images. Ultimately the goal of intake-STAC is to facilitate loading these *Assets* directly into Python objects for interactive computation without worrying about filepaths and URLs.<jupyter_code>%matplotlib inline
import intake
# intake checks for registered drivers when imported
# You should see 'stac_catalog, stac_collection, stac_item, and stac_item_collection' if intake-stac is installed
list(intake.registry)<jupyter_output><empty_output><jupyter_text>Catalog adapterWe'll start by connecting to the STAC Catalog for `planet-disaster-data`. We read the top-level `catalog.json` file and drill down until we get to specific STAC Items.<jupyter_code># Load root catalog
url = 'https://raw.githubusercontent.com/cholmes/sample-stac/master/stac/catalog.json'
cat = intake.open_stac_catalog(url)
print(cat.name)

# This lists available subcatalogs:
list(cat)
# STAC files are in JSON format, which is accessible as Python dictionaries:
cat.metadata
# Drill down into subcatalogs
subcat = cat['hurricane-harvey']
list(subcat)
# Another subcatalog!
subcat1 = subcat['hurricane-harvey-0831']
list(subcat1)
# Load a STAC Item
item = subcat1['Houston-East-20170831-103f-100d-0f4f-RGB']
item.metadata
# Item Assets are accessible via lists just like subcatalogs:
list(item)
item['thumbnail'].metadata
# Finally we can display an image!
from IPython.display import Image
Image(item['thumbnail'].urlpath)
# Or we can load the image directly into Xarray for analysis
# The full resolution image is big, but we use dask behind the scenes to only read metadata at first
asset = item['mosaic']
da = asset.to_dask()
da
# The chunk structure isn't set by default
# setting a chunk structure makes operating on subsets of pixels more efficient
da = da.chunk(dict(band=1, x=2560, y=2560))
da
da.isel(band=0, x=slice(0, 2560), y=slice(0, 1280)).plot.imshow()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09553608677513559, 'fraction_numerical': 0.017939090529828953, 'mean_word_length': 5.95072463768116, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '133469', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 760, 'n_tokens_neox': 711, 'n_words': 258, 'path': 'examples/planet-disaster-data.ipynb', 'repo_name': 'kthyng/intake-stac', 'size': '2397'}