Exemplo n.º 1
0
    def features(self):
        """Get or sets a list of :class:`~pystac.Item` contained in this Single File STAC.

        Returns:
            List[Item]
        """
        features = self.catalog.extra_fields.get('features')
        if features is None:
            raise STACError('Invalid Single File STAC: does not have "features" property.')

        return [pystac.read_dict(feature) for feature in features]
Exemplo n.º 2
0
    def collections(self):
        """Get or sets a list of :class:`~pystac.Collection` objects contained
        in this Single File STAC.

        Returns:
            List[Band]
        """
        collections = self.catalog.extra_fields.get('collections')

        if collections is not None:
            collections = [pystac.read_dict(col) for col in collections]
        return collections
Exemplo n.º 3
0
def migrate(path: str) -> None:
    try:
        with open(path) as f:
            stac_json = json.load(f)
    except json.decoder.JSONDecodeError:
        print(f"Cannot read {path}")
        raise

    if "stac_version" in stac_json:
        cur_ver = stac_json["stac_version"]
        if not cur_ver == TARGET_VERSION:
            print("  - Migrating {} from {} to {}...".format(
                path, cur_ver, TARGET_VERSION))
            obj = pystac.read_dict(stac_json, href=path)
            migrated = obj.to_dict(include_self_link=False)
            with open(path, "w") as f:
                json.dump(migrated, f, indent=2)
Exemplo n.º 4
0
 def test_read_catalog_dict(self) -> None:
     catalog_dict = self.stac_io.read_json(
         TestCases.get_path("data-files/catalogs/test-case-1/catalog.json"))
     catalog = pystac.read_dict(catalog_dict)
     self.assertIsInstance(catalog, pystac.Catalog)
Exemplo n.º 5
0
 def test_read_collection_dict(self) -> None:
     collection_dict = self.stac_io.read_json(
         TestCases.get_path("data-files/collections/multi-extent.json"))
     collection = pystac.read_dict(collection_dict)
     self.assertIsInstance(collection, pystac.Collection)
Exemplo n.º 6
0
 def test_read_item_dict(self) -> None:
     item_dict = self.stac_io.read_json(
         TestCases.get_path("data-files/item/sample-item.json"))
     item = pystac.read_dict(item_dict)
     self.assertIsInstance(item, pystac.Item)