Пример #1
0
    def test_asset_providers(self):
        item = pystac.read_file(
            TestCases.get_path(
                'data-files/item/sample-item-asset-properties.json'))
        cm = item.common_metadata

        item_value = cm.providers
        a2_known_value = [
            pystac.Provider(name="USGS",
                            url="https://landsat.usgs.gov/",
                            roles=["producer", "licensor"])
        ]

        # Get
        a1_value = cm.get_providers(item.assets['analytic'])
        a2_value = cm.get_providers(item.assets['thumbnail'])
        self.assertEqual(a1_value[0].to_dict(), item_value[0].to_dict())
        self.assertNotEqual(a2_value[0].to_dict(), item_value[0].to_dict())
        self.assertEqual(a2_value[0].to_dict(), a2_known_value[0].to_dict())

        # Set
        set_value = [
            pystac.Provider(name="John Snow",
                            url="https://cholera.com/",
                            roles=["producer"])
        ]
        cm.set_providers(set_value, item.assets['analytic'])
        new_a1_value = cm.get_providers(item.assets['analytic'])
        self.assertEqual(new_a1_value[0].to_dict(), set_value[0].to_dict())
        self.assertEqual(cm.providers[0].to_dict(), item_value[0].to_dict())
Пример #2
0
import os
from shutil import rmtree
from tempfile import mkdtemp
from typing import TYPE_CHECKING, Dict, List

import pystac
import ulid
from linz_logger import get_log

from topo_processor.util import Validity

GLOBAL_PROVIDERS = [
    pystac.Provider(name="LINZ",
                    description="Land Information New Zealand",
                    roles=["Host"])
]
if TYPE_CHECKING:
    from .item import Item

TEMP_DIR = None


class Collection(Validity):
    title: str
    description: str
    license: str
    items: Dict[str, "Item"]
    providers: List[pystac.Provider]

    def __init__(self, title: str):
        super().__init__()
Пример #3
0
import pystac
from pystac.link import Link
from pystac.extensions.eo import Band

SENTINEL_LICENSE = Link(rel='license',
                        target='https://sentinel.esa.int/documents/' +
                        '247904/690755/Sentinel_Data_Legal_Notice')

SENTINEL_INSTRUMENTS = ['msi']
SENTINEL_CONSTELLATION = 'Sentinel 2'

SENTINEL_PROVIDER = pystac.Provider(
    name='ESA',
    roles=['producer', 'processor', 'licensor'],
    url='https://earth.esa.int/web/guest/home')

SAFE_MANIFEST_ASSET_KEY = "safe-manifest"
INSPIRE_METADATA_ASSET_KEY = "inspire-metadata"
PRODUCT_METADATA_ASSET_KEY = "product-metadata"
GRANULE_METADATA_ASSET_KEY = "granule-metadata"
DATASTRIP_METADATA_ASSET_KEY = "datastrip-metadata"

SENTINEL_BANDS = {
    'B01':
    Band.create(name='B01',
                common_name='coastal',
                description='Band 1 - Coastal aerosol',
                center_wavelength=0.443,
                full_width_half_max=0.027),
    'B02':
    Band.create(name='B02',
Пример #4
0
def create_item(tif_href, additional_providers=None):
    """Creates a STAC Item from Copernicus Global Land Cover Layers data.
    Args:
        tif_href (str): The href to the metadata for this tif.
    This function will read the metadata file for information to place in
    the STAC item.
    Returns:
        pystac.Item: A STAC Item representing this Copernicus Global Land Cover Layers data.
    """

    with rio.open(tif_href) as f:
        tags = f.tags()
        band_tags = f.tags(1)
        bounds = f.bounds

    # Item id
    item_id = os.path.basename(tif_href).replace('.tif', '')

    # Bounds
    geom = mapping(box(bounds.left, bounds.bottom, bounds.right, bounds.top))
    bounds = shape(geom).bounds

    start_dt = str_to_datetime(tags.pop('time_coverage_start'))
    end_dt = str_to_datetime(tags.pop('time_coverage_end'))
    file_creation_dt = str_to_datetime(tags.pop('file_creation'))

    item = pystac.Item(id=item_id,
                       geometry=geom,
                       bbox=bounds,
                       datetime=None,
                       properties={
                           'start_datetime':
                           start_dt,
                           'end_datetime':
                           end_dt,
                           'discrete_classification_class_names':
                           DISCRETE_CLASSIFICATION_CLASS_NAMES,
                           'discrete_classification_class_palette':
                           DISCRETE_CLASSIFICATION_CLASS_PALETTE
                       })

    # Common metadata
    copernicus_provider = pystac.Provider(name=PROVIDER_NAME,
                                          url=(tags.pop('doi')),
                                          roles=['producer', 'licensor'])

    item.common_metadata.providers = [copernicus_provider]
    if additional_providers is not None:
        item.common_metadata.providers.extend(additional_providers)

    item.common_metadata.start_datetime = start_dt
    item.common_metadata.end_datetime = end_dt
    item.common_metadata.created = file_creation_dt

    item.common_metadata.description = tags.pop('Info')
    item.common_metadata.platform = tags.pop('platform')
    item.common_metadata.title = tags.pop('title')

    # proj
    item.ext.enable('projection')
    item.ext.projection.epsg = int(
        tags.pop('delivered_product_crs').replace('WGS84 (EPSG:',
                                                  '').replace(')', ''))

    # Extra fields
    for k, v in tags.items():
        item.extra_fields[k] = v

    # Bands
    long_name = band_tags.pop('long_name')
    band = pystac.extensions.eo.Band.create(
        name=long_name,
        common_name=band_tags.pop('short_name'),
        description=long_name)

    item.ext.enable('eo')
    item.ext.eo.bands = [band]

    # Tif
    item.add_asset(
        ITEM_TIF_IMAGE_NAME,
        pystac.Asset(href=tif_href,
                     media_type=pystac.MediaType.TIFF,
                     roles=['data'],
                     title="tif image"))
    return item
Пример #5
0
during the agricultural growing seasons in the continental U.S.

NAIP projects are contracted each year based upon available funding and the
FSA imagery acquisition cycle. Beginning in 2003, NAIP was acquired on
a 5-year cycle. 2008 was a transition year, and a three-year cycle began
in 2009.

NAIP imagery is acquired at a one-meter ground sample distance (GSD) with a
horizontal accuracy that matches within six meters of photo-identifiable
ground control points, which are used during image inspection.

Older images were collected using 3 bands (Red, Green, and Blue: RGB), but
newer imagery is usually collected with an additional near-infrared band
(RGBN).
""".strip('\n')

NAIP_LICENSE = 'PDDL-1.0'

USDA_PROVIDER = pystac.Provider(
    name='USDA Farm Service Agency',
    url=('https://www.fsa.usda.gov/programs-and-services/aerial-photography'
         '/imagery-programs/naip-imagery/'),
    roles=['producer', 'licensor'])

NAIP_BANDS = [
    Band.create(name="Red", common_name='red'),
    Band.create(name="Green", common_name='green'),
    Band.create(name="Blue", common_name='blue'),
    Band.create(name="NIR", common_name='nir', description="near-infrared")
]
Пример #6
0
import pystac
import rasterio as rio

from stactools.core.io import ReadHrefModifier
from stactools.aster.constants import (
    ASTER_INSTRUMENT, ASTER_PLATFORM, ASTER_SENSORS, HDF_ASSET_KEY,
    ASTER_BANDS, QA_BROWSE_ASSET_KEY, QA_TXT_ASSET_KEY, SWIR_SENSOR,
    TIR_BROWSE_ASSET_KEY, TIR_SENSOR, VNIR_SENSOR, VNIR_BROWSE_ASSET_KEY,
    XML_ASSET_KEY)
from stactools.aster.xml_metadata import XmlMetadata
from stactools.aster.utils import (AsterSceneId, get_sensors_to_bands)

logger = logging.getLogger(__name__)

ASTER_PROVIDER = pystac.Provider(
    name='NASA LP DAAC at the USGS EROS Center',
    url='https://doi.org/10.5067/ASTER/AST_L1T.003',
    roles=['producer', 'processor', 'licensor'])


def _add_cog_assets(
        item: pystac.Item,
        xml_metadata: XmlMetadata,
        vnir_cog_href: Optional[str],
        swir_cog_href: Optional[str],
        tir_cog_href: Optional[str],
        read_href_modifier: Optional[ReadHrefModifier] = None) -> None:

    pointing_angles = xml_metadata.pointing_angles

    sensors_to_hrefs = {
        VNIR_SENSOR: vnir_cog_href,