Description:
- PySTAC is a library for working with SpatioTemporal Asset Catalogs (STAC) in Python 3.
Resources:
Example 1
Section titled “Example 1”Write a STAC catalog to a file and read it back
import jsonfrom pathlib import Path
from pystac import Catalog
tmp = "/tmp/demo_notebooks"Path(tmp).mkdir(exist_ok=True)
# Example stac catalogexample_catalog = { "type": "Catalog", "stac_version": "1.0.0", "stac_extensions": [], "id": "landsat-stac-collection-catalog", "title": "STAC for Landsat data", "description": "STAC for Landsat data", "links": [ { "href": "./catalog.json", "rel": "self" }, { "href": "./catalog.json", "rel": "root" }, { "href": "./landsat-8-l1/collection.json", "rel": "child" } ]}
# Create a json file locally with the dictwith open(f"{tmp}/stac_catalog.json", 'w') as f: json.dump(example_catalog, f)
# Print attrs from the catalogroot_catalog = Catalog.from_file(f"{tmp}/stac_catalog.json")print(f"ID: {root_catalog.id}")print(f"Title: {root_catalog.title or 'N/A'}")print(f"Description: {root_catalog.description or 'N/A'}")ganymede is made by Eugo