Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
66 changes: 66 additions & 0 deletions create_stac.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env python3

#
# Creates a STAC catalog from a nested dictionary of GEoTIF files
#

from pathlib import Path
import pystac
import rasterio
from shapely.geometry import Polygon, mapping
from datetime import datetime


catalog = pystac.Catalog(
id="rqa-deforestation-test-data",
description="RQADeforestation test data. Subset of Sentinel-1 Sigma0 containing the tile E051N018T3.",
)

collection = pystac.Collection(
id="rqa-deforestation-test-data",
description="RQADeforestation test data. Subset of Sentinel-1 Sigma0 containing the tile E051N018T3.",
extent=pystac.Extent(
spatial=pystac.SpatialExtent([[-180.0, -90.0, 180.0, 90.0]]),
temporal=pystac.TemporalExtent(
[[datetime(2020, 1, 1), datetime(2022, 12, 31)]]
),
),
)


def to_stac_item(raster_uri):
with rasterio.open(raster_uri) as ds:
bounds = ds.bounds
bbox = [bounds.left, bounds.bottom, bounds.right, bounds.top]
footprint = Polygon(
[
[bounds.left, bounds.bottom],
[bounds.left, bounds.top],
[bounds.right, bounds.top],
[bounds.right, bounds.bottom],
]
)
tags = ds.tags()
datetime = dt.fromisoformat(tags["sensing_date"])
item = pystac.Item(
id=raster_uri + ".json",
geometry=mapping(footprint),
bbox=bbox,
datetime=datetime,
properties=tags,
href=raster_uri,
)
item.add_asset(
key="image",
asset=pystac.Asset(href=raster_uri, media_type=pystac.MediaType.GEOTIFF),
)
return item


for path in list(Path(".").rglob("*.tif")):
raster_uri = str(path)
item = to_stac_item(raster_uri)
collection.add_item(item)

catalog.add_child(collection)
catalog.normalize_and_save("stac", catalog_type=pystac.CatalogType.SELF_CONTAINED)
18 changes: 18 additions & 0 deletions stac/catalog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "Catalog",
"id": "rqa-deforestation-test-data",
"stac_version": "1.1.0",
"description": "RQADeforestation test data. Subset of Sentinel-1 Sigma0 containing the tile E051N018T3.",
"links": [
{
"rel": "root",
"href": "./catalog.json",
"type": "application/json"
},
{
"rel": "child",
"href": "./rqa-deforestation-test-data/collection.json",
"type": "application/json"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"type": "Feature",
"stac_version": "1.1.0",
"stac_extensions": [],
"id": "V0M2R4/EQUI7_EU020M/E051N018T3/SIG0_20200701T050807__VH_D022_E051N018T3_EU020M_V0M2R4_S1BIWGRDH_TUWIEN.tif.json",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
5255000.0,
2031510.0
],
[
5255000.0,
2032990.0
],
[
5256000.0,
2032990.0
],
[
5256000.0,
2031510.0
],
[
5255000.0,
2031510.0
]
]
]
},
"bbox": [
5255000.0,
2031510.0,
5256000.0,
2032990.0
],
"properties": {
"abs_orbit_number": "22273",
"border_noise_removed": "True",
"creation_date": "2021-03-08 22:55:11",
"creator": "gfm_ops",
"dem_source": "/eodc/private/jrc_gfm/gfm_scratch/copdem/CopDEM30m_global_mosaic.tif",
"egm_applied": "False",
"encoding_info": "Values were multiplied by 10. No data value was set to -9999.",
"mode": "IW",
"modification_date": "2022-09-10 22:29:24",
"orbit_file_type": "POEORB",
"parent": "S1B_IW_GRDH_1SDV_20200701T050807_20200701T050832_022273_02A458_BE83.zip",
"polarisation": "VH",
"rel_orbit_number": "22",
"run_number": "4",
"satellite_id": "S1B",
"sensing_date": "2020-07-01 05:08:07",
"slice_gap_filled": "True",
"slice_overlap_removed": "False",
"snap_version": "7.0",
"spatial_filter": "none",
"thermal_noise_removed": "True",
"value_info": "Sigma nought radar backscatter coefficient in dB.",
"worker_git_commit": "none",
"worker_git_tag": "from v0.2.3 to v0.2.4",
"worker_name": "s1_sigma",
"wrapper_git_commit": "none",
"wrapper_git_tag": "v0.1.4",
"wrapper_name": "sentinel_1_reprocessing",
"AREA_OR_POINT": "Area",
"datetime": "2020-07-01T05:08:07Z"
},
"links": [
{
"rel": "root",
"href": "../../../../../../../../catalog.json",
"type": "application/json"
},
{
"rel": "collection",
"href": "../../../../../../../collection.json",
"type": "application/json"
},
{
"rel": "parent",
"href": "../../../../../../../collection.json",
"type": "application/json"
}
],
"assets": {
"image": {
"href": "../../../../../../../../../V0M2R4/EQUI7_EU020M/E051N018T3/V0M2R4/EQUI7_EU020M/E051N018T3/SIG0_20200701T050807__VH_D022_E051N018T3_EU020M_V0M2R4_S1BIWGRDH_TUWIEN.tif",
"type": "image/tiff; application=geotiff"
}
},
"collection": "rqa-deforestation-test-data"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"type": "Feature",
"stac_version": "1.1.0",
"stac_extensions": [],
"id": "V0M2R4/EQUI7_EU020M/E051N018T3/SIG0_20200701T050832__VH_D022_E051N018T3_EU020M_V0M2R4_S1BIWGRDH_TUWIEN.tif.json",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
5255000.0,
2031510.0
],
[
5255000.0,
2032990.0
],
[
5256000.0,
2032990.0
],
[
5256000.0,
2031510.0
],
[
5255000.0,
2031510.0
]
]
]
},
"bbox": [
5255000.0,
2031510.0,
5256000.0,
2032990.0
],
"properties": {
"abs_orbit_number": "22273",
"border_noise_removed": "True",
"creation_date": "2021-03-08 22:15:52",
"creator": "gfm_ops",
"dem_source": "/eodc/private/jrc_gfm/gfm_scratch/copdem/CopDEM30m_global_mosaic.tif",
"egm_applied": "False",
"encoding_info": "Values were multiplied by 10. No data value was set to -9999.",
"mode": "IW",
"modification_date": "2022-09-10 22:30:31",
"orbit_file_type": "POEORB",
"parent": "S1B_IW_GRDH_1SDV_20200701T050832_20200701T050857_022273_02A458_A235.zip",
"polarisation": "VH",
"rel_orbit_number": "22",
"run_number": "4",
"satellite_id": "S1B",
"sensing_date": "2020-07-01 05:08:32",
"slice_gap_filled": "True",
"slice_overlap_removed": "False",
"snap_version": "7.0",
"spatial_filter": "none",
"thermal_noise_removed": "True",
"value_info": "Sigma nought radar backscatter coefficient in dB.",
"worker_git_commit": "none",
"worker_git_tag": "from v0.2.3 to v0.2.4",
"worker_name": "s1_sigma",
"wrapper_git_commit": "none",
"wrapper_git_tag": "v0.1.4",
"wrapper_name": "sentinel_1_reprocessing",
"AREA_OR_POINT": "Area",
"datetime": "2020-07-01T05:08:32Z"
},
"links": [
{
"rel": "root",
"href": "../../../../../../../../catalog.json",
"type": "application/json"
},
{
"rel": "collection",
"href": "../../../../../../../collection.json",
"type": "application/json"
},
{
"rel": "parent",
"href": "../../../../../../../collection.json",
"type": "application/json"
}
],
"assets": {
"image": {
"href": "../../../../../../../../../V0M2R4/EQUI7_EU020M/E051N018T3/V0M2R4/EQUI7_EU020M/E051N018T3/SIG0_20200701T050832__VH_D022_E051N018T3_EU020M_V0M2R4_S1BIWGRDH_TUWIEN.tif",
"type": "image/tiff; application=geotiff"
}
},
"collection": "rqa-deforestation-test-data"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"type": "Feature",
"stac_version": "1.1.0",
"stac_extensions": [],
"id": "V0M2R4/EQUI7_EU020M/E051N018T3/SIG0_20200701T050857__VH_D022_E051N018T3_EU020M_V0M2R4_S1BIWGRDH_TUWIEN.tif.json",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
5255000.0,
2031510.0
],
[
5255000.0,
2032990.0
],
[
5256000.0,
2032990.0
],
[
5256000.0,
2031510.0
],
[
5255000.0,
2031510.0
]
]
]
},
"bbox": [
5255000.0,
2031510.0,
5256000.0,
2032990.0
],
"properties": {
"abs_orbit_number": "22273",
"border_noise_removed": "True",
"creation_date": "2021-03-08 21:37:07",
"creator": "gfm_ops",
"dem_source": "/eodc/private/jrc_gfm/gfm_scratch/copdem/CopDEM30m_global_mosaic.tif",
"egm_applied": "False",
"encoding_info": "Values were multiplied by 10. No data value was set to -9999.",
"mode": "IW",
"modification_date": "2022-09-10 22:32:49",
"orbit_file_type": "POEORB",
"parent": "S1B_IW_GRDH_1SDV_20200701T050857_20200701T050922_022273_02A458_A83F.zip",
"polarisation": "VH",
"rel_orbit_number": "22",
"run_number": "4",
"satellite_id": "S1B",
"sensing_date": "2020-07-01 05:08:57",
"slice_gap_filled": "True",
"slice_overlap_removed": "False",
"snap_version": "7.0",
"spatial_filter": "none",
"thermal_noise_removed": "True",
"value_info": "Sigma nought radar backscatter coefficient in dB.",
"worker_git_commit": "none",
"worker_git_tag": "from v0.2.3 to v0.2.4",
"worker_name": "s1_sigma",
"wrapper_git_commit": "none",
"wrapper_git_tag": "v0.1.4",
"wrapper_name": "sentinel_1_reprocessing",
"AREA_OR_POINT": "Area",
"datetime": "2020-07-01T05:08:57Z"
},
"links": [
{
"rel": "root",
"href": "../../../../../../../../catalog.json",
"type": "application/json"
},
{
"rel": "collection",
"href": "../../../../../../../collection.json",
"type": "application/json"
},
{
"rel": "parent",
"href": "../../../../../../../collection.json",
"type": "application/json"
}
],
"assets": {
"image": {
"href": "../../../../../../../../../V0M2R4/EQUI7_EU020M/E051N018T3/V0M2R4/EQUI7_EU020M/E051N018T3/SIG0_20200701T050857__VH_D022_E051N018T3_EU020M_V0M2R4_S1BIWGRDH_TUWIEN.tif",
"type": "image/tiff; application=geotiff"
}
},
"collection": "rqa-deforestation-test-data"
}
Loading