Skip to content

Instantly share code, notes, and snippets.

@asjohnston-asf
Created December 2, 2022 21:41
Show Gist options
  • Save asjohnston-asf/e8453bfb370abf49a0122d4b26c1148c to your computer and use it in GitHub Desktop.
Save asjohnston-asf/e8453bfb370abf49a0122d4b26c1148c to your computer and use it in GitHub Desktop.
"Search the GSSICB STAC Catalog" notebook for AGU 2022
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "e2c43438-2d9d-4cf4-9cc9-925e7ed4a801",
"metadata": {},
"source": [
"# Search the GSSICB STAC Catalog"
]
},
{
"cell_type": "markdown",
"id": "b2f6cd57-334f-43f4-a55c-7188cc003a44",
"metadata": {
"tags": []
},
"source": [
"## 1. Install pystac-client\n",
"\n",
"[pystac-client](https://pystac-client.readthedocs.io/en/stable/) is a Python package for working with STAC APIs."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7f1cd282-46f4-4c5d-b2ef-b03fb44a0cb1",
"metadata": {},
"outputs": [],
"source": [
"!pip install pystac-client"
]
},
{
"cell_type": "markdown",
"id": "00f8c8a0-6f5d-48b0-a6b2-4ac82446bc96",
"metadata": {},
"source": [
"## 2. Connect to the API"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "6e32dc19-19af-4132-98f4-bbfe82961eb8",
"metadata": {},
"outputs": [],
"source": [
"from pprint import pprint\n",
"from pystac_client import Client\n",
"\n",
"client = Client.open('https://stac.asf.alaska.edu/')"
]
},
{
"cell_type": "markdown",
"id": "2b122706-498a-4140-b36d-c488f6f70399",
"metadata": {},
"source": [
"## 3. Inspect the data set\n",
"\n",
"A STAC [collection](https://github.com/radiantearth/stac-spec/blob/master/collection-spec/collection-spec.md) provides metadata about a data set as a whole, such as documentation, licensing, and data extent. A collection's [summaries](https://github.com/radiantearth/stac-spec/
blob/master/collection-spec/collection-spec.md#summaries) describe data set properties that are available when searching."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "9674acda-eab9-4072-9225-e9a82fc25a68",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Global Seasonal Sentinel-1 Interferometric Coherence and Backscatter Data Set\n",
"{'sar:polarizations': ['VV', 'VH', 'HH', 'HV'],\n",
" 'sar:product_type': ['COH06', 'COH12', 'COH18', 'COH24', 'COH36', 'COH48', 'AMP', 'rho', 'rmse', 'tau', 'inc', 'lsmap'],\n",
" 'season': ['spring', 'summer', 'fall', 'winter']}\n"
]
}
],
"source": [
"collection = client.get_collection('sentinel-1-global-coherence')\n",
"print(collection.title)\n",
"pprint(collection.summaries.lists, width=150)"
]
},
{
"cell_type": "markdown",
"id": "c520af74-8dd2-451b-aecf-424476219e70",
"metadata": {},
"source": [
"## 4. Search for data\n",
"\n",
"A STAC [item](https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md) represents a specific asset in a data set, such as a GeoTIFF file. Users can search for items using a combination of geographic coordinates and item metadata, including product type (CO
H12, COH24, AMP, etc.), season, polarization, and tile name. Search results include metadata about each item, including links to the data itself."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "4b3dc5ed-c48d-45ab-a9ad-f56a79dc1c07",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://sentinel-1-global-coherence-earthbigdata.s3.us-west-2.amazonaws.com/data/tiles/N43W089/N43W089_fall_vv_COH12.tif\n",
"https://sentinel-1-global-coherence-earthbigdata.s3.us-west-2.amazonaws.com/data/tiles/N43W088/N43W088_fall_vv_COH12.tif\n",
"https://sentinel-1-global-coherence-earthbigdata.s3.us-west-2.amazonaws.com/data/tiles/N43W087/N43W087_fall_vv_COH12.tif\n",
"https://sentinel-1-global-coherence-earthbigdata.s3.us-west-2.amazonaws.com/data/tiles/N42W089/N42W089_fall_vv_COH12.tif\n",
"https://sentinel-1-global-coherence-earthbigdata.s3.us-west-2.amazonaws.com/data/tiles/N42W088/N42W088_fall_vv_COH12.tif\n",
"https://sentinel-1-global-coherence-earthbigdata.s3.us-west-2.amazonaws.com/data/tiles/N42W087/N42W087_fall_vv_COH12.tif\n",
"https://sentinel-1-global-coherence-earthbigdata.s3.us-west-2.amazonaws.com/data/tiles/N41W089/N41W089_fall_vv_COH12.tif\n",
"https://sentinel-1-global-coherence-earthbigdata.s3.us-west-2.amazonaws.com/data/tiles/N41W088/N41W088_fall_vv_COH12.tif\n",
"https://sentinel-1-global-coherence-earthbigdata.s3.us-west-2.amazonaws.com/data/tiles/N41W087/N41W087_fall_vv_COH12.tif\n"
]
}
],
"source": [
"search_results = client.search(\n",
" collections=['sentinel-1-global-coherence'],\n",
" bbox=[-88, 41, -87, 42], # Hello, Chicago!\n",
" query=['season=fall', 'sar:product_type=COH12'],\n",
")\n",
"for item in search_results.items():\n",
" print(item.assets['data'].href)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dd3fe062-6ee8-4a89-85e0-a3f758e5330f",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment