Skip to content

Commit

Permalink
Merge pull request #38 from fkroeber/stac_querying
Browse files Browse the repository at this point in the history
feat: Add STACCube 🎁
  • Loading branch information
luukvdmeer authored Mar 5, 2024
2 parents 4676dd5 + 9d7ec4f commit 7714f8c
Show file tree
Hide file tree
Showing 17 changed files with 1,645 additions and 37 deletions.
1,049 changes: 1,029 additions & 20 deletions demo/datacube.ipynb

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
208 changes: 208 additions & 0 deletions demo/files/layout_stac.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
{
"reflectance": {
"s2_band01": {
"name": "coastal",
"description": "Coastal aerosol band (~443nm; 60m spatial resolution). Top of atmosphere (TOA) reflectance captured by the multi-spectral instrument (MSI) of Sentinel-2A or Sentinel-2B as band 1.",
"type": "continuous",
"values": {
"min": 0,
"max": 1,
"precision": 1
},
"copyright": "Contains modified Copernicus data."
},
"s2_band02": {
"name": "blue",
"description": "Blue band (~494nm; 10m spatial resolution). Top of atmosphere (TOA) reflectance captured by the multi-spectral instrument (MSI) of Sentinel-2A or Sentinel-2B as band 2.",
"type": "continuous",
"values": {
"min": 0,
"max": 1,
"precision": 1
},
"role": "blue",
"copyright": "Contains modified Copernicus data."
},
"s2_band03": {
"name": "green",
"description": "Green band (~560nm; 10m spatial resolution). Top of atmosphere (TOA) reflectance captured by the multi-spectral instrument (MSI) of Sentinel-2A or Sentinel-2B as band 3.",
"type": "continuous",
"values": {
"min": 0,
"max": 1,
"precision": 1
},
"role": "green",
"copyright": "Contains modified Copernicus data."
},
"s2_band04": {
"name": "red",
"description": "Red band (~665nm; 10m spatial resolution). Top of atmosphere (TOA) reflectance captured by the multi-spectral instrument (MSI) of Sentinel-2A or Sentinel-2B as band 4.",
"type": "continuous",
"values": {
"min": 0,
"max": 1,
"precision": 1
},
"role": "red",
"copyright": "Contains modified Copernicus data."
},
"s2_band05": {
"name": "rededge1",
"description": "Vegetation red edge (VRE) band (~704nm; 20m spatial resolution). Top of atmosphere (TOA) reflectance captured by the multi-spectral instrument (MSI) of Sentinel-2A or Sentinel-2B as band 5.",
"type": "continuous",
"values": {
"min": 0,
"max": 1,
"precision": 1
},
"copyright": "Contains modified Copernicus data."
},
"s2_band06": {
"name": "rededge2",
"description": "Vegetation red edge (VRE) band (~740nm; 20m spatial resolution). Top of atmosphere (TOA) reflectance captured by the multi-spectral instrument (MSI) of Sentinel-2A or Sentinel-2B as band 6.",
"type": "continuous",
"values": {
"min": 0,
"max": 1,
"precision": 1
},
"copyright": "Contains modified Copernicus data."
},
"s2_band07": {
"name": "rededge3",
"description": "Vegetation red edge (VRE) band (~781nm; 20m spatial resolution). Top of atmosphere (TOA) reflectance captured by the multi-spectral instrument (MSI) of Sentinel-2A or Sentinel-2B as band 7.",
"type": "continuous",
"values": {
"min": 0,
"max": 1,
"precision": 1
},
"copyright": "Contains modified Copernicus data."
},
"s2_band08": {
"name": "nir",
"description": "Near infrared (NIR) band (~834nm; 10m spatial resolution). Top of atmosphere (TOA) reflectance captured by the multi-spectral instrument (MSI) of Sentinel-2A or Sentinel-2B as band 8.",
"type": "continuous",
"values": {
"min": 0,
"max": 1,
"precision": 1
},
"copyright": "Contains modified Copernicus data."
},
"s2_band08A": {
"name": "nir08",
"description": "Narrow near infrared (NIR) band (~864nm; 20m spatial resolution). Top of atmosphere (TOA) reflectance captured by the multi-spectral instrument (MSI) of Sentinel-2A or Sentinel-2B as band 8A.",
"type": "continuous",
"values": {
"min": 0,
"max": 1,
"precision": 1
},
"copyright": "Contains modified Copernicus data."
},
"s2_band09": {
"name": "nir09",
"description": "Water vapour band (~944nm; 60m spatial resolution). Top of atmosphere (TOA) reflectance captured by the multi-spectral instrument (MSI) of Sentinel-2A or Sentinel-2B as band 9.",
"type": "continuous",
"values": {
"min": 0,
"max": 1,
"precision": 1
},
"copyright": "Contains modified Copernicus data."
},
"s2_band11": {
"name": "swir16",
"description": "Shortwave infrared (SWIR) band (~1612nm; 20m spatial resolution). Top of atmosphere (TOA) reflectance captured by the multi-spectral instrument (MSI) of Sentinel-2A or Sentinel-2B as band 11.",
"type": "continuous",
"values": {
"min": 0,
"max": 1,
"precision": 1
},
"copyright": "Contains modified Copernicus data."
},
"s2_band12": {
"name": "swir22",
"description": "Shortwave infrared (SWIR) band (~2195nm; 20m spatial resolution). Top of atmosphere (TOA) reflectance captured by the multi-spectral instrument (MSI) of Sentinel-2A or Sentinel-2B as band 12.",
"type": "continuous",
"values": {
"min": 0,
"max": 1,
"precision": 1
},
"copyright": "Contains modified Copernicus data."
}
},
"appearance": {
"scl": {
"name": "scl",
"description": "SCL categories (as provided by Sen2Cor processor)",
"type": "ordinal",
"values": [
{
"id": 0,
"label": "mask",
"description": "no data"
},
{
"id": 1,
"label": "saturated",
"description": "saturated/defective"
},
{
"id": 2,
"label": "dark",
"description": "dark areas"
},
{
"id": 3,
"label": "shadow",
"description": "cloud shadows"
},
{
"id": 4,
"label": "vegetation",
"description": "vegetation"
},
{
"id": 5,
"label": "bare",
"description": "not vegetated"
},
{
"id": 6,
"label": "water",
"description": "water"
},
{
"id": 7,
"label": "unknown",
"description": "unclassified"
},
{
"id": 8,
"label": "cl_med",
"description": "cloud medium probability"
},
{
"id": 9,
"label": "cl_high",
"description": "cloud high probability"
},
{
"id": 10,
"label": "cl_cirrus",
"description": "cloud (thin cirrus)"
},
{
"id": 11,
"label": "snow",
"description": "snow"
}
]
}
}
}
4 changes: 2 additions & 2 deletions demo/gallery.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
" mapping = sq.mapping.Semantique(json.load(file))\n",
"\n",
"# Represent an EO data cube.\n",
"with open(\"files/layout.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers.zip\")\n",
"with open(\"files/layout_gtiff.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers_gtiff.zip\")\n",
"\n",
"# Set the spatio-temporal extent.\n",
"space = sq.SpatialExtent(gpd.read_file(\"files/footprint.geojson\"))\n",
Expand Down
8 changes: 4 additions & 4 deletions demo/mapping.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@
"metadata": {},
"outputs": [],
"source": [
"with open(\"files/layout.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers.zip\")\n",
"with open(\"files/layout_gtiff.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers_gtiff.zip\")\n",
" \n",
"layout = dc.layout"
]
Expand Down Expand Up @@ -527,8 +527,8 @@
"metadata": {},
"outputs": [],
"source": [
"with open(\"files/layout.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers.zip\")"
"with open(\"files/layout_gtiff.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers_gtiff.zip\")"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions demo/processor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
" mapping = sq.mapping.Semantique(json.load(file))\n",
"\n",
"# Represent an EO data cube.\n",
"with open(\"files/layout.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers.zip\")\n",
"with open(\"files/layout_gtiff.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers_gtiff.zip\")\n",
"\n",
"# Set the spatio-temporal extent.\n",
"space = sq.SpatialExtent(gpd.read_file(\"files/footprint.geojson\"))\n",
Expand Down
4 changes: 2 additions & 2 deletions demo/recipes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@
"metadata": {},
"outputs": [],
"source": [
"with open(\"files/layout.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers.zip\")"
"with open(\"files/layout_gtiff.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers_gtiff.zip\")"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions demo/references.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@
"metadata": {},
"outputs": [],
"source": [
"with open(\"files/layout.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers.zip\")"
"with open(\"files/layout_gtiff.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers_gtiff.zip\")"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions demo/test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
" mapping = sq.mapping.Semantique(json.load(file))\n",
"\n",
"# Represent an EO data cube.\n",
"with open(\"files/layout.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers.zip\")\n",
"with open(\"files/layout_gtiff.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers_gtiff.zip\")\n",
"\n",
"# Set the spatio-temporal extent.\n",
"space = sq.SpatialExtent(gpd.read_file(\"files/footprint.geojson\"))\n",
Expand Down
4 changes: 2 additions & 2 deletions demo/verbs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
" mapping = sq.mapping.Semantique(json.load(file))\n",
"\n",
"# Represent an EO data cube.\n",
"with open(\"files/layout.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers.zip\")\n",
"with open(\"files/layout_gtiff.json\", \"r\") as file:\n",
" dc = sq.datacube.GeotiffArchive(json.load(file), src = \"files/layers_gtiff.zip\")\n",
"\n",
"# Set the spatio-temporal extent.\n",
"space = sq.SpatialExtent(gpd.read_file(\"files/footprint.geojson\"))\n",
Expand Down
1 change: 1 addition & 0 deletions docs/source/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ EO data cube
datacube.Datacube
datacube.Opendatacube
datacube.GeotiffArchive
datacube.STACCube

Spatio-temporal extent
-----------------------
Expand Down
6 changes: 6 additions & 0 deletions docs/source/reference_hide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
datacube.GeotiffArchive.lookup
datacube.GeotiffArchive.retrieve

datacube.STACCube.layout
datacube.STACCube.src
datacube.STACCube.config
datacube.STACCube.lookup
datacube.STACCube.retrieve

extent.SpatialExtent.features
extent.SpatialExtent.crs
extent.SpatialExtent.from_geojson
Expand Down
3 changes: 3 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ dependencies:
- pandas
- pyproj
- pytz
- pystac
- rasterio
- rioxarray
- scipy
- xarray
- pip
- pip:
- hvplot
- pystack-client
- stackstac
- .
Loading

0 comments on commit 7714f8c

Please sign in to comment.