### Run Jupyter Notebooks for Tutorials Source: https://github.com/stac-utils/pystac/blob/main/README.md Start a Jupyter notebook server in the 'docs' directory to access and run quickstart and tutorial notebooks. ```shell jupyter notebook --ip 0.0.0.0 --port 8888 --notebook-dir=docs ``` -------------------------------- ### Install PySTAC from PyPI Source: https://github.com/stac-utils/pystac/blob/main/README.md Install the core PySTAC library using pip. This is the recommended installation method. ```shell python -m pip install pystac ``` -------------------------------- ### Install PySTAC Locally Source: https://github.com/stac-utils/pystac/blob/main/docs/contributing.md Clone the PySTAC repository and install it locally using uv. Ensure you activate the virtual environment after installation. ```bash git clone git@github.com:your_user_name/pystac.git cd pystac uv sync source .venv/bin/activate ``` -------------------------------- ### Install PySTAC from Source Source: https://github.com/stac-utils/pystac/blob/main/README.md Clone the PySTAC repository and install it locally from the source code. ```shell git clone https://github.com/stac-utils/pystac.git cd pystac python -m pip install . ``` -------------------------------- ### Install PySTAC from Source Source: https://github.com/stac-utils/pystac/blob/main/docs/installation.md Install PySTAC directly from its GitHub repository. This is useful for development or when needing the latest unreleased code. ```bash pip install git+https://github.com/stac-utils/pystac.git ``` -------------------------------- ### Link Extension Example Source: https://github.com/stac-utils/pystac/blob/main/docs/api/link.md This example demonstrates how to set an extension field on a link. Ensure the relevant extension is loaded. ```python link.ext.file.size = 8675309 ``` -------------------------------- ### Install PySTAC and Dependencies Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/how-to-create-stac-catalogs.ipynb Installs the pystac library along with boto3, rasterio, and shapely. Use this command in your environment before running the tutorial. ```python %pip install boto3 rasterio shapely pystac --quiet ``` -------------------------------- ### Install PySTAC with orjson Support Source: https://github.com/stac-utils/pystac/blob/main/README.md Install PySTAC with optional orjson support for faster JSON serialization/deserialization. ```shell python -m pip install 'pystac[orjson]' ``` -------------------------------- ### Install PySTAC from PyPI Source: https://github.com/stac-utils/pystac/blob/main/docs/installation.md Use this command to install the latest stable version of PySTAC from the Python Package Index. ```bash pip install pystac ``` -------------------------------- ### Install PySTAC and Planetary Computer Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/creating-a-landsat-stac.ipynb Installs PySTAC with validation extras and the Planetary Computer package. Requires Jupyter to be installed locally. ```bash pip install 'pystac[validation]' planetary-computer ``` -------------------------------- ### Install PySTAC with Validation Support Source: https://github.com/stac-utils/pystac/blob/main/README.md Install PySTAC with optional validation features, which requires the jsonschema library. ```shell python -m pip install 'pystac[validation]' ``` -------------------------------- ### Install pytest-pystac Source: https://github.com/stac-utils/pystac/blob/main/pytest-pystac/README.md Install the pytest-pystac plugin using pip. ```shell pip install pytest-pystac ``` -------------------------------- ### Install PySTAC with Jinja2 Support Source: https://github.com/stac-utils/pystac/blob/main/README.md Install PySTAC with optional Jinja2 support for enabling pretty display of pystac objects in Jupyter notebooks. ```shell python -m pip install 'pystac[jinja2]' ``` -------------------------------- ### Install PySTAC with urllib3 Support Source: https://github.com/stac-utils/pystac/blob/main/README.md Install PySTAC with optional urllib3 support for retrying network requests, useful for custom RetryStacIO or non-ASCII URLs. ```shell python -m pip install 'pystac[urllib3]' ``` -------------------------------- ### Install PySTAC from conda-forge Source: https://github.com/stac-utils/pystac/blob/main/docs/installation.md Install PySTAC using the conda package manager from the conda-forge channel. ```bash conda install -c conda-forge pystac ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/stac-utils/pystac/blob/main/docs/contributing.md Install Git pre-commit hooks to automatically run linters and formatters on staged code before committing. Use --overwrite to ensure the latest configuration is applied. ```bash pre-commit install --overwrite ``` -------------------------------- ### Install PySTAC with urllib3 Extras Source: https://github.com/stac-utils/pystac/blob/main/docs/installation.md Install PySTAC with the 'urllib3' extra, which is used in RetryStacIO for enhanced network request handling. This adds the 'urllib3' dependency. ```bash pip install pystac[urllib3] ``` -------------------------------- ### Install PySTAC with Jinja2 Extras Source: https://github.com/stac-utils/pystac/blob/main/docs/installation.md Install PySTAC with the 'jinja2' extra to enable pretty representations of PySTAC objects in Jupyter notebooks. This adds the 'jinja2' dependency. ```bash pip install pystac[jinja2] ``` -------------------------------- ### Install Specific PySTAC Version for STAC v0.9.x Source: https://github.com/stac-utils/pystac/blob/main/docs/installation.md Install a specific version of PySTAC (e.g., 0.4.0) to ensure compatibility with older STAC specification versions like v0.9.x. ```bash pip install pystac==0.4.0 ``` -------------------------------- ### Accessing Collection Extension Properties Source: https://github.com/stac-utils/pystac/blob/main/docs/api/collection.md Use the `.ext` accessor to get extension classes for a collection. This example shows how to access the xarray extension. ```python print(collection.ext.xarray) ``` -------------------------------- ### Get All Items Recursively Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/pystac-introduction.ipynb Retrieve all STAC Item objects located anywhere within the STAC tree, starting from the current object. This traverses all nested catalogs and collections. ```python # get all items anywhere below this catalog on the STAC tree list(cat.get_items(recursive=True)) ``` -------------------------------- ### Define Collection Extent Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/creating-a-landsat-stac.ipynb Set the spatial and temporal extent for the STAC Collection. This example defines a global spatial extent and an open-ended temporal interval starting from a specific date. ```python spatial_extent = pystac.SpatialExtent([[-180.0, -90.0, 180.0, 90.0]]) temporal_extent = pystac.TemporalExtent([[datetime(2013, 6, 1), None]]) collection_extent = pystac.Extent(spatial_extent, temporal_extent) ``` -------------------------------- ### Example Benchmark Comparison Output Source: https://github.com/stac-utils/pystac/blob/main/docs/contributing.md Illustrates a typical output format for benchmark comparisons between different versions, showing performance metrics and ratios. ```text before after ratio [eee06027] [579c071b] - 533±20μs 416±10μs 0.78 collection.CollectionBench.time_collection_from_file [gadomski/virtualenv-py3.10-orjson] - 329±8μs 235±10μs 0.72 collection.CollectionBench.time_collection_from_dict [gadomski/virtualenv-py3.10-orjson] - 332±10μs 231±4μs 0.70 collection.CollectionBench.time_collection_from_dict [gadomski/virtualenv-py3.10] - 174±4μs 106±2μs 0.61 item.ItemBench.time_item_from_dict [gadomski/virtualenv-py3.10] - 174±4μs 106±2μs 0.61 item.ItemBench.time_item_from_dict [gadomski/virtualenv-py3.10-orjson] before after ratio [eee06027] [579c071b] + 87.1±3μs 124±5μs 1.42 catalog.CatalogBench.time_catalog_from_dict [gadomski/virtualenv-py3.10] + 87.1±4μs 122±5μs 1.40 catalog.CatalogBench.time_catalog_from_dict [gadomski/virtualenv-py3.10-orjson] ``` -------------------------------- ### Display Collection Initialization Help Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/creating-a-landsat-stac.ipynb Shows the signature for the pystac.Collection constructor, detailing the required and optional parameters for creating a Collection object. ```python help(pystac.Collection.__init__) ``` -------------------------------- ### Display pystac.Item.__init__ signature Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/creating-a-landsat-stac.ipynb Use the `help` method to view the signature of the `pystac.Item.__init__` method for understanding required arguments. ```python help(pystac.Item.__init__) ``` -------------------------------- ### Get Projection Extension Schema URI Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/projection.md Gets the schema URI associated with the Projection Extension. ```python uri = ProjectionExtension.get_schema_uri() ``` -------------------------------- ### Initialize a pystac Collection Source: https://github.com/stac-utils/pystac/blob/main/docs/api/pystac.md Create a new STAC Collection with essential metadata like ID, description, and extent. Optional parameters allow for title, extensions, license, keywords, providers, summaries, assets, and layout strategy. ```python pystac.Collection(id='my-collection', description='A detailed description of my collection.', extent=pystac.utils.make_simple_extent([-10, -20], [10, 20]), title='My Collection Title', license='CC-BY-4.0', keywords=['example', 'data'], providers=[pystac.Provider(name='Provider Name', roles=['host'], url='https://example.com')], summaries={'gsd': {'minimum': 10, 'maximum': 100}}, assets={'thumbnail': pystac.Asset(href='https://example.com/thumbnail.jpg', media_type='image/jpeg', title='Thumbnail')}, strategy=pystac.layout.BestPracticesLayoutStrategy()) ``` -------------------------------- ### Inspect pystac.Catalog Initialization Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/how-to-create-stac-catalogs.ipynb Displays the initialization signature and docstring for the pystac.Catalog class to understand its required and optional parameters. ```python ?pystac.Catalog ``` -------------------------------- ### Initialize New Catalog Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/pystac-introduction.ipynb Create a new STAC Catalog object with a specified ID and description. By default, a new catalog is set as its own root. ```python # create a Catalog object with JSON mycat = pystac.Catalog(id="mycat", description="My shiny new STAC catalog") ``` -------------------------------- ### Get Projection Extension Schema URIs Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/projection.md Gets a list of all schema URIs associated with the Projection Extension. ```python uris = ProjectionExtension.get_schema_uris() ``` -------------------------------- ### Create a STAC Catalog Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/how-to-create-stac-catalogs.ipynb Instantiates a STAC Catalog with an ID and description. Requires pystac. ```python catalog = pystac.Catalog(id="spacenet5", description="Spacenet 5 Data (Test)") ``` -------------------------------- ### Inspect pystac.Item Initialization Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/how-to-create-stac-catalogs.ipynb Displays the initialization signature and docstring for the pystac.Item class, detailing the parameters needed to create a STAC Item. ```python ?pystac.Item ``` -------------------------------- ### Run Development Benchmarks Source: https://github.com/stac-utils/pystac/blob/main/docs/contributing.md Executes a shortened version of the benchmark suite for faster iteration during development. Ensure benchmark dependencies are installed. ```bash asv dev ``` -------------------------------- ### Create Temporary Directory for Saving Source: https://github.com/stac-utils/pystac/blob/main/docs/quickstart.ipynb Prepare a temporary directory on the local filesystem to store the normalized STAC catalog. ```python # Create a temporary directory tmp_dir = tempfile.mkdtemp() ``` -------------------------------- ### Get current UTC time Source: https://github.com/stac-utils/pystac/blob/main/docs/api/utils.md Use `now_in_utc` to get a `datetime` object representing the current time, with the UTC timezone explicitly set. ```python from pystac.utils import now_in_utc print(now_in_utc()) ``` -------------------------------- ### Get or Set Item Projection Code Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/projection.md Gets or sets the projection code of the datasource, such as 'EPSG:4326'. This replaces the older 'proj:epsg' property. ```python code = item.ext.proj.code ``` ```python item.ext.proj.code = 'EPSG:4326' ``` -------------------------------- ### Render.apply Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/render.md Sets the properties for a new Render, defining how assets should be rendered. ```APIDOC ## Render.apply ### Description Set the properties for a new Render. This method defines how assets are used and visualized in a rendered output. ### Method `apply` ### Parameters * **assets** (list[str]) - Required - List of asset keys referencing the assets that are used to make the rendering. * **title** (str | None) - Optional - Title of the rendering. * **rescale** (list[list[float]] | None) - Optional - A list of min/max value pairs to rescale each asset by, e.g. `[[0, 5000], [0, 7000], [0, 9000]]`. If not provided, the assets will not be rescaled. * **nodata** (float | str | None) - Optional - Nodata value. * **colormap_name** (str | None) - Optional - Name of color map to apply to the render. See: [https://matplotlib.org/stable/gallery/color/colormap_reference.html](https://matplotlib.org/stable/gallery/color/colormap_reference.html) * **colormap** (dict[str, Any] | None) - Optional - A dictionary containing a custom colormap definition. See: [https://developmentseed.org/titiler/advanced/rendering/#custom-colormaps](https://developmentseed.org/titiler/advanced/rendering/#custom-colormaps) * **color_formula** (str | None) - Optional - A string containing a color formula to apply color corrections to images. Useful for reducing artifacts like atmospheric haze, dark shadows, or muted colors. See: [https://developmentseed.org/titiler/advanced/rendering/#color-formula](https://developmentseed.org/titiler/advanced/rendering/#color-formula) * **resampling** (str | None) - Optional - Resampling algorithm to apply to the referenced assets. See GDAL resampling algorithm for some examples. [https://gdal.org/en/latest/programs/gdalwarp.html#cmdoption-gdalwarp-r](https://gdal.org/en/latest/programs/gdalwarp.html#cmdoption-gdalwarp-r) * **expression** (str | None) - Optional - Band arithmetic formula to apply to the referenced assets. * **minmax_zoom** (list[int] | None) - Optional - Zoom level range applicable for the visualization, e.g. `[2, 18]`. ``` -------------------------------- ### Get Latest Version Link Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/version.md Access the `latest` property of a VersionExtension instance to get or set the Link to the STAC object representing the most recent version. ```python >>> latest_link = version_ext.latest ``` -------------------------------- ### Create a Render object Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/render.md Use the `create` class method to instantiate a `Render` object. This method takes a list of asset keys and various optional parameters to define how the assets should be rendered. ```python Render.create(assets=["asset1.tif", "asset2.tif"], title="My Render", rescale=[[0, 10000]], nodata=-9999, colormap_name="viridis", color_formula="Gamma(1.5)", resampling="bilinear", expression="B1/B2", minmax_zoom=[2, 16]) ``` -------------------------------- ### Read Data using STAC Reference File Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/how-to-read-data-from-stac.ipynb This example shows how to open a dataset using a STAC asset that points to a reference file (e.g., for kerchunk). It signs the asset and uses the `patch_url` argument in `xarray.open_dataset`. ```python cmip6_collection = pystac.Collection.from_file( "https://planetarycomputer.microsoft.com/api/stac/v1/collections/nasa-nex-gddp-cmip6" ) cmip6_asset = cmip6_collection.assets["ACCESS-CM2.historical"] cmip6_asset_signed = planetary_computer.sign(cmip6_asset) ds = xr.open_dataset(cmip6_asset_signed, chunks={}, patch_url=planetary_computer.sign) ``` -------------------------------- ### Get or Set Item Shape Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/projection.md Gets or sets the number of pixels in the Y and X directions for the default grid. This is used for assets that don't have an overriding shape. ```python shape = item.ext.proj.shape ``` ```python item.ext.proj.shape = [y_pixels, x_pixels] ``` -------------------------------- ### Get Datacube Extension for an Item Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/datacube.md Use DatacubeExtension.ext() to get the Datacube Extension for an Item. This is the recommended way to extend STAC objects with Datacube properties. ```python >>> item: pystac.Item = ... >>> dc_ext = DatacubeExtension.ext(item) ``` -------------------------------- ### Example Asset Metadata Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/creating-a-landsat-stac.ipynb Demonstrates the structure for defining an asset's type, title, and detailed classification bitfields. ```json { "type": "image/tiff; application=geotiff; profile=cloud-optimized", "title": "Aerosol Quality Assessment Band", "classification:bitfields": [ { "offset": 0, "length": 1, "classes": [ { "value": 0, "name": "not_fill", "description": "Pixel is not fill" }, { "value": 1, "name": "fill", "description": "Pixel is fill" } ], "description": "Image or fill data", "name": "fill" }, { "offset": 1, "length": 1, "classes": [ { "value": 0, "name": "not_valid", "description": "Pixel retrieval is not valid" }, { "value": 1, "name": "valid", "description": "Pixel retrieval is valid" } ], "description": "Valid aerosol retrieval", "name": "retrieval" }, { "offset": 2, "length": 1, "classes": [ { "value": 0, "name": "not_water", "description": "Pixel is not water" }, { "value": 1, "name": "water", "description": "Pixel is water" } ], "description": "Water mask", "name": "water" }, { "offset": 5, "length": 1, "classes": [ { "value": 0, "name": "not_interpolated", "description": "Pixel is not interpolated" }, { "value": 1, "name": "interpolated", "description": "Pixel is interpolated" } ], "description": "Aerosol interpolation", "name": "interpolated" }, { "offset": 6, "length": 2, "classes": [ { "value": 0, "name": "climatology", "description": "No aerosol correction applied" }, { "value": 1, "name": "low", "description": "Low aerosol level" }, { "value": 2, "name": "medium", "description": "Medium aerosol level" }, { "value": 3, "name": "high", "description": "High aerosol level" } ], "description": "Aerosol level", "name": "level" } ] } ``` -------------------------------- ### Import Pystac Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/pystac-introduction.ipynb Import the pystac library to begin working with STAC objects. ```python import pystac ``` -------------------------------- ### Get or Set Item EPSG Code Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/projection.md Gets or sets the EPSG code of the datasource. Set to None if no valid EPSG code exists or if the data does not have a CRS. ```python epsg_code = item.ext.proj.epsg ``` ```python item.ext.proj.epsg = 4326 ``` -------------------------------- ### Python Import Style Guide Source: https://github.com/stac-utils/pystac/blob/main/docs/contributing.md Demonstrates the preferred Python import style for consistency. Avoid importing modules with aliases unless necessary for type checking. ```python # DO from datetime import datetime # DON'T import datetime import datetime as dt ``` -------------------------------- ### Get or Set Item Bounding Box Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/projection.md Gets or sets the bounding box of the assets represented by this item. The format (4 or 6 coordinates) depends on the CRS. ```python bbox = item.ext.proj.bbox ``` ```python item.ext.proj.bbox = [west, south, east, north] ``` -------------------------------- ### Get or Set Item PROJJSON Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/projection.md Gets or sets the PROJJSON string representing the Coordinate Reference System (CRS). This is used for proj:geometry and proj:bbox fields. ```python projjson_data = item.ext.proj.projjson ``` ```python item.ext.proj.projjson = { ... } ``` -------------------------------- ### Read Example Catalog Source: https://github.com/stac-utils/pystac/blob/main/docs/quickstart.ipynb Read a STAC catalog from a local file path using Catalog.from_file. This is useful for loading an existing catalog structure. ```python root_catalog = Catalog.from_file("./example-catalog/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'}") ``` -------------------------------- ### Get or Set Item Geometry Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/projection.md Gets or sets a Polygon GeoJSON dict representing the footprint of this item. The geometry is based on the CRS defined in code, projjson, or wkt2 fields. ```python geometry = item.ext.proj.geometry ``` ```python item.ext.proj.geometry = { ... } ``` -------------------------------- ### Initialize a pystac Catalog Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/pystac-spacenet-tutorial.ipynb Creates an in-memory pystac Catalog object with a specified ID and description. This serves as the root for organizing STAC collections and items. ```python spacenet = pystac.Catalog(id="spacenet", description="SpaceNet 2 STAC") ``` -------------------------------- ### Create a STAC Catalog Instance Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/how-to-create-stac-catalogs.ipynb Initializes a new STAC Catalog with a unique ID and a descriptive string. The HREF is not set at this stage. ```python catalog = pystac.Catalog(id="test-catalog", description="Tutorial catalog.") ``` -------------------------------- ### Run Continuous Benchmarks Source: https://github.com/stac-utils/pystac/blob/main/docs/contributing.md Compares the current HEAD with the main branch to report performance improvements or regressions. Requires benchmark dependencies to be installed. ```bash asv continuous --split -e --interleave-rounds --factor 1.25 main HEAD ``` -------------------------------- ### Get EO Extension Summaries for Collection Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/eo.md Use the summaries class method to get the extended summaries object for a given STAC Collection, enabling access to EO-specific summary statistics. ```python >>> summaries = EOExtension.summaries(collection) ``` -------------------------------- ### strategy Source: https://github.com/stac-utils/pystac/blob/main/docs/api/pystac.md Gets or sets the HrefLayoutStrategy for this object. ```APIDOC ## property strategy *: [HrefLayoutStrategy](layout.md#pystac.layout.HrefLayoutStrategy) | None* ### Description Gets or sets the HrefLayoutStrategy for this object. ``` -------------------------------- ### ItemAssetDefinition.description Source: https://github.com/stac-utils/pystac/blob/main/docs/api/item_assets.md Gets or sets a description of the Asset. ```APIDOC ## ItemAssetDefinition.description ### Description Gets or sets a description of the Asset providing additional details, such as how it was processed or created. [CommonMark 0.29](http://commonmark.org/) syntax MAY be used for rich text representation. ### Property `description: str | None` ``` -------------------------------- ### code Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/projection.md Get or set the code of the datasource. ```APIDOC ## code ### Description Get or set the code of the datasource. Added in version 2.0.0 of this extension replacing “proj:epsg”. Projection codes are identified by a string. The [proj](https://proj.org/) library defines projections using “authority:code”, e.g., “EPSG:4326” or “IAU_2015:30100”. Different projection authorities may define different string formats. ### Type str | None ``` -------------------------------- ### Inspect pystac Collection Initialization Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/how-to-create-stac-catalogs.ipynb Displays the initialization signature and docstring for the pystac.Collection class. Use this to understand the required and optional parameters for creating a STAC Collection. ```python ?pystac.Collection ``` -------------------------------- ### description Source: https://github.com/stac-utils/pystac/blob/main/docs/api/asset.md Gets or sets the description of the asset. ```APIDOC ## description ### Description A description of the Asset providing additional details, such as how it was processed or created. CommonMark 0.29 syntax MAY be used for rich text representation. ### Property type str | None ``` -------------------------------- ### Creating a StorageScheme Object Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/storage.md Use the `StorageScheme.create()` class method to instantiate a storage scheme. This method requires 'type' and 'platform' and can optionally include 'region', 'requester_pays', and other custom properties. ```python >>> storage_scheme = StorageScheme.create(type='S3', platform='s3.amazonaws.com', region='us-east-1', requester_pays=True) ``` -------------------------------- ### ItemAssetDefinition.roles Source: https://github.com/stac-utils/pystac/blob/main/docs/api/item_assets.md Gets or sets the semantic roles of the asset. ```APIDOC ## ItemAssetDefinition.roles ### Description Gets or sets the [semantic roles](https://github.com/radiantearth/stac-spec/tree/v1.0.0/item-spec/item-spec.md#asset-role-types) of the asset, similar to the use of rel in links. ### Property `roles: list[str] | None` ``` -------------------------------- ### ItemAssetDefinition.media_type Source: https://github.com/stac-utils/pystac/blob/main/docs/api/item_assets.md Gets or sets the media type of the asset. ```APIDOC ## ItemAssetDefinition.media_type ### Description Gets or sets the [media type](https://github.com/radiantearth/stac-spec/tree/v1.0.0/catalog-spec/catalog-spec.md#media-types) of the asset. ### Property `media_type: str | None` ``` -------------------------------- ### StorageExtension.apply Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/storage.md Applies storage schemes and references to the extension. ```APIDOC ## StorageExtension.apply ### Description Applies storage schemes and references to the extension. ### Method ```python apply(*, schemes: dict[str, StorageScheme] | None = None, refs: list[str] | None = None) -> None ``` ### Parameters * **schemes** (dict[str, StorageScheme] | None) - A dictionary of storage schemes to apply. * **refs** (list[str] | None) - A list of references to apply. ``` -------------------------------- ### Applying Satellite Extension Properties Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/sat.md Shows how to use the `apply()` method on a `SatExtension` instance to set various satellite-related properties. ```APIDOC ## Applying SatExtension Properties ### Description The `apply()` method on a `SatExtension` instance allows you to set multiple satellite-related properties at once. You must provide at least one of `orbit_state` or `relative_orbit` for the extension properties to be considered valid. ### Method `apply(orbit_state: OrbitState | None = None, relative_orbit: int | None = None, absolute_orbit: int | None = None, platform_international_designator: str | None = None, anx_datetime: datetime | None = None) -> None` ### Parameters * **orbit_state** (`OrbitState` or `None`) - The state of the orbit (e.g., ascending, descending, geostationary). * **relative_orbit** (`int` or `None`) - The non-negative integer of the orbit number at the time of acquisition. * **absolute_orbit** (`int` or `None`) - The absolute orbit number of the item. * **platform_international_designator** (`str` or `None`) - The international designator of the platform. * **anx_datetime** (`datetime` or `None`) - The datetime of the ascending node crossing. ### Example ```python from datetime import datetime from pystac.extensions.sat import SatExtension, OrbitState # Assuming 'sat_ext' is an instance of SatExtension obtained via SatExtension.ext(item) sat_ext: SatExtension sat_ext.apply( orbit_state=OrbitState.ASCENDING, relative_orbit=500, absolute_orbit=15000, platform_international_designator="123-ABC", anx_datetime=datetime(2023, 10, 27, 10, 30, 0) ) ``` ``` -------------------------------- ### BaseVersionExtension.get_schema_uri Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/version.md Gets the schema URI associated with this extension. ```APIDOC ## BaseVersionExtension.get_schema_uri ### Description Gets the schema URI associated with this extension. ### Method `classmethod get_schema_uri() -> str` ### Returns The schema URI as a string. ``` -------------------------------- ### StorageExtension.get_schema_uri Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/storage.md Gets the schema URI associated with this extension. ```APIDOC ## StorageExtension.get_schema_uri ### Description Gets the schema URI associated with this extension. ### Method ```python classmethod get_schema_uri() -> str ``` ### Returns str: The schema URI. ``` -------------------------------- ### Extending Collection Summaries with Projection Extension Source: https://github.com/stac-utils/pystac/blob/main/docs/concepts.md Demonstrates how to add and set properties for the Projection extension on a collection's summaries. Ensure the Projection extension is available. ```python import pystac from pystac.extensions.projection import ProjectionExtension # Load a collection that does not implement the Projection extension collection = pystac.Collection.from_file( "tests/data-files/examples/1.0.0/collection.json" ) # Add Projection extension summaries to the collection proj = ProjectionExtension.summaries(collection, add_if_missing=True) print(collection.stac_extensions) # [ # ...., # 'https://stac-extensions.github.io/projection/v1.1.0/schema.json' # ] # Set the values for various extension fields proj.epsg = [4326] collection_as_dict = collection.to_dict() collection_as_dict["summaries"]["proj:epsg"] # [4326] ``` -------------------------------- ### Statistic.count Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/pointcloud.md Gets or sets the count property for this Statistic. ```APIDOC ## Statistic.count ### Description Gets or sets the count property. ### Property int | None ``` -------------------------------- ### Asset Class Initialization Source: https://github.com/stac-utils/pystac/blob/main/docs/api/asset.md Initializes a new Asset object with its href and optional metadata. ```APIDOC ## Asset Class ### Description Represents a link to data associated with an Item or Collection that can be downloaded or streamed. ### Parameters * **href** (str) - Required - Link to the asset object. Relative and absolute links are both allowed. * **title** (str | None) - Optional - Optional displayed title for clients and users. * **description** (str | None) - Optional - A description of the Asset providing additional details. * **media_type** (str | None) - Optional - Optional description of the media type. Registered Media Types are preferred. * **roles** (list[str] | None) - Optional - Semantic roles of the asset (e.g., thumbnail, overview, data, metadata). * **extra_fields** (dict[str, Any] | None) - Optional - Additional fields for this asset, used by extensions. ``` -------------------------------- ### Statistic.average Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/pointcloud.md Gets or sets the average property for this Statistic. ```APIDOC ## Statistic.average ### Description Gets or sets the average property. ### Property float | None ``` -------------------------------- ### TableExtension.get_schema_uri() Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/table.md Gets the schema URI associated with this extension. ```APIDOC ## TableExtension.get_schema_uri() ### Description Gets the schema URI associated with this extension. ### Method `classmethod` ### Returns str: The schema URI. ### Example ```python from pystac.extensions.table import TableExtension schema = TableExtension.get_schema_uri() ``` ``` -------------------------------- ### Download Sample Image Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/how-to-create-stac-catalogs.ipynb Downloads a sample GeoTIFF image to a temporary directory. This sets up the data for creating a STAC catalog. ```python import os import urllib.request from tempfile import TemporaryDirectory tmp_dir = TemporaryDirectory() img_path = os.path.join(tmp_dir.name, "image.tif") ``` ```python url = ( "https://spacenet-dataset.s3.amazonaws.com/" "spacenet/SN5_roads/train/AOI_7_Moscow/MS/" "SN5_roads_train_AOI_7_Moscow_MS_chip996.tif" ) urllib.request.urlretrieve(url, img_path) ``` -------------------------------- ### TableExtension.row_count Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/table.md Get or set the number of rows in the dataset. ```APIDOC ## TableExtension.row_count ### Description The number of rows in the dataset. ### Property `row_count` (int | None) ### Example ```python # Assuming 'tbl_ext' is an instance of TableExtension num_rows = tbl_ext.row_count ``` ``` -------------------------------- ### Run All Pre-commit Checks Source: https://github.com/stac-utils/pystac/blob/main/docs/contributing.md Execute all configured pre-commit hooks on all files in the repository. This is useful for a comprehensive code quality check. ```bash pre-commit run --all-files ``` -------------------------------- ### Import pystac and necessary libraries Source: https://github.com/stac-utils/pystac/blob/main/docs/tutorials/pystac-spacenet-tutorial.ipynb Imports core pystac components along with `datetime`, `os.path`, `boto3`, `rasterio`, `shapely`, and `pystac`. These are required for STAC creation, data handling, and spatial operations. ```python from datetime import datetime from os.path import basename, join import boto3 import rasterio from shapely.geometry import GeometryCollection, box, mapping, shape import pystac ``` -------------------------------- ### Schema.size Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/pointcloud.md Gets or sets the size value for this Schema. ```APIDOC ## Schema.size ### Description Gets or sets the size value. ### Property int ``` -------------------------------- ### Extend Asset with File Extension Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/file.md Use FileExtension.ext() to extend an Asset with file properties. This is the recommended way to instantiate the FileExtension. ```python >>> asset: pystac.Asset = ... >>> file_ext = FileExtension.ext(asset) ``` -------------------------------- ### get_schema_uri Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/projection.md Gets the schema URI associated with this extension. ```APIDOC ## get_schema_uri() ### Description Gets the schema URI associated with this extension. ### Method classmethod ### Returns str - The schema URI. ``` -------------------------------- ### Schema.name Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/pointcloud.md Gets or sets the name property for this Schema. ```APIDOC ## Schema.name ### Description Gets or sets the name property for this Schema. ### Property str ``` -------------------------------- ### Create an Asset Instance from Definition Source: https://github.com/stac-utils/pystac/blob/main/docs/api/item_assets.md The `create_asset` method generates a `pystac.Asset` object using the properties defined in the `ItemAssetDefinition` and a provided href. ```python asset = collection.item_assets["data"].create_asset("http://example.com/data.tiff") ``` -------------------------------- ### TemplateLayoutStrategy Initialization Source: https://github.com/stac-utils/pystac/blob/main/docs/api/layout.md Initializes a TemplateLayoutStrategy with custom templates for catalogs, collections, and items. A fallback strategy can also be provided. ```python strategy = TemplateLayoutStrategy(catalog_template="${catalog_id}", collection_template="${collection_id}/${date}", item_template="${item_id}.json") ``` -------------------------------- ### epsg Source: https://github.com/stac-utils/pystac/blob/main/docs/api/extensions/projection.md Get or sets the EPSG code of the datasource. ```APIDOC ## epsg ### Description Get or sets the EPSG code of the datasource. A Coordinate Reference System (CRS) is the data reference system (sometimes called a ‘projection’) used by the asset data, and can usually be referenced using an [EPSG code](https://epsg.io/). If the asset data does not have a CRS, such as in the case of non-rectified imagery with Ground Control Points, `epsg` should be set to `None`. It should also be set to `None` if a CRS exists, but for which there is no valid EPSG code. ### Type int | None ```