-
-
Save palmerj/a78dc0b99da0720266ac19c736785802 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import pystac as stac | |
bbox = [178.1228614, -38.6535161, 178.1398058, -38.6470536] | |
collection_bbox = list(bbox) | |
spatial_extent = stac.SpatialExtent(bboxes=[collection_bbox]) | |
collection_interval = list([datetime.utcnow(), None]) | |
temporal_extent = stac.TemporalExtent(intervals=[collection_interval]) | |
collection_extent = stac.Extent(spatial=spatial_extent, temporal=temporal_extent) | |
catalog = stac.Catalog(id="aerial-imagery", description="Catalog") | |
a_catalog = stac.Catalog(id="region-a", description="Region A") | |
catalog.add_child(a_catalog) | |
d = datetime.utcnow() | |
properties = { | |
"created": d.isoformat("T") + "Z", | |
"datetime": "2017-03-31T00:00:00Z", | |
} | |
collection = stac.Collection( | |
id="test_dataset_1", | |
description="test_dataset_1 description", | |
title="test collection", | |
extent=collection_extent, | |
properties=properties, | |
license="CC-BY-4.0", | |
) | |
bbox = [178.2851242, -37.5871129, 178.2880601, -37.5837602] | |
footprint = { | |
"type": "Polygon", | |
"coordinates": [ | |
[ | |
[178.2851242, -37.5838818], | |
[178.2853533, -37.5871129], | |
[178.2880601, -37.5869913], | |
[178.2878309, -37.5837602], | |
[178.2851242, -37.5838818], | |
] | |
], | |
} | |
asset_props = {"checksum:sha1": "7794f1f78ebfc330564833eac736a19da908f2f7"} | |
item1 = stac.Item( | |
id="BD44_500_031096", geometry=footprint, bbox=bbox, stac_extensions=["checksum"], properties=asset_props, datetime=d, | |
) | |
# item1.set_self_href("/tmp/test-catalog/test_dataset_1/BD44_500_031096.json") | |
item1.add_asset( | |
key="image", asset=stac.Asset(href="./BD44_500_031096.tif", properties=asset_props, media_type=stac.MediaType.GEOTIFF) | |
) | |
collection.add_item(item1) | |
a_catalog.add_child(collection) | |
catalog.normalize_hrefs("/tmp/test-catalog") | |
catalog.save(catalog_type=stac.CatalogType.SELF_CONTAINED) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment