diff --git a/notebooks/datasets/nceo-biomass-statistics.ipynb b/notebooks/datasets/nceo-biomass-statistics.ipynb index 6bcb2d64..2cd7e1bc 100644 --- a/notebooks/datasets/nceo-biomass-statistics.ipynb +++ b/notebooks/datasets/nceo-biomass-statistics.ipynb @@ -100,33 +100,9 @@ "cell_type": "code", "execution_count": 1, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: rasterstats in /srv/conda/envs/notebook/lib/python3.10/site-packages (0.18.0)\n", - "Requirement already satisfied: fiona<1.9 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from rasterstats) (1.8.22)\n", - "Requirement already satisfied: shapely in /srv/conda/envs/notebook/lib/python3.10/site-packages (from rasterstats) (1.8.5.post1)\n", - "Requirement already satisfied: cligj>=0.4 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from rasterstats) (0.7.2)\n", - "Requirement already satisfied: simplejson in /srv/conda/envs/notebook/lib/python3.10/site-packages (from rasterstats) (3.19.1)\n", - "Requirement already satisfied: affine<3.0 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from rasterstats) (2.3.1)\n", - "Requirement already satisfied: click>7.1 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from rasterstats) (8.1.3)\n", - "Requirement already satisfied: numpy>=1.9 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from rasterstats) (1.23.5)\n", - "Requirement already satisfied: rasterio>=1.0 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from rasterstats) (1.3.4)\n", - "Requirement already satisfied: attrs>=17 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from fiona<1.9->rasterstats) (22.2.0)\n", - "Requirement already satisfied: six>=1.7 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from fiona<1.9->rasterstats) (1.16.0)\n", - "Requirement already satisfied: setuptools in /srv/conda/envs/notebook/lib/python3.10/site-packages (from fiona<1.9->rasterstats) (65.6.3)\n", - "Requirement already satisfied: certifi in /srv/conda/envs/notebook/lib/python3.10/site-packages (from fiona<1.9->rasterstats) (2022.12.7)\n", - "Requirement already satisfied: click-plugins>=1.0 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from fiona<1.9->rasterstats) (1.1.1)\n", - "Requirement already satisfied: munch in /srv/conda/envs/notebook/lib/python3.10/site-packages (from fiona<1.9->rasterstats) (2.5.0)\n", - "Requirement already satisfied: snuggs>=1.4.1 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from rasterio>=1.0->rasterstats) (1.4.7)\n", - "Requirement already satisfied: pyparsing>=2.1.6 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from snuggs>=1.4.1->rasterio>=1.0->rasterstats) (3.0.9)\n" - ] - } - ], + "outputs": [], "source": [ - "!pip install rasterstats" + "!pip install rasterstats --quiet" ] }, { @@ -153,7 +129,7 @@ "outputs": [], "source": [ "# Provide STAC API endpoint\n", - "STAC_API_URL = \"https://staging-stac.delta-backend.com/\"\n", + "STAC_API_URL = \"https://openveda.cloud/api/stac/\"\n", "\n", "# Declare collection of interest - NCEO Biomass\n", "collection = \"nceo_africa_2017\"" @@ -206,28 +182,28 @@ " 'type': 'image/tiff; application=geotiff; profile=cloud-optimized',\n", " 'title': 'Default COG Layer',\n", " 'description': 'Cloud optimized default layer to display on map',\n", - " 'raster:bands': [{'scale': 1.0,\n", + " 'raster:bands': [{'scale': 1,\n", " 'nodata': 'inf',\n", - " 'offset': 0.0,\n", + " 'offset': 0,\n", " 'sampling': 'area',\n", " 'data_type': 'uint16',\n", - " 'histogram': {'max': 429.0,\n", - " 'min': 0.0,\n", - " 'count': 11.0,\n", - " 'buckets': [405348.0,\n", - " 44948.0,\n", - " 18365.0,\n", - " 6377.0,\n", - " 3675.0,\n", - " 3388.0,\n", - " 3785.0,\n", - " 9453.0,\n", - " 13108.0,\n", - " 1186.0]},\n", + " 'histogram': {'max': 429,\n", + " 'min': 0,\n", + " 'count': 11,\n", + " 'buckets': [405348,\n", + " 44948,\n", + " 18365,\n", + " 6377,\n", + " 3675,\n", + " 3388,\n", + " 3785,\n", + " 9453,\n", + " 13108,\n", + " 1186]},\n", " 'statistics': {'mean': 37.58407913145342,\n", " 'stddev': 81.36678677343947,\n", - " 'maximum': 429.0,\n", - " 'minimum': 0.0,\n", + " 'maximum': 429,\n", + " 'minimum': 0,\n", " 'valid_percent': 50.42436439336373}}],\n", " 'roles': ['data', 'layer']}" ] @@ -247,18 +223,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Explore through the item's assets. We can see from the data's statistics values that the `min` and `max` values for the observed values range from `0` to `429` Mg ha-1. \n", - "\n", - "Exploring the properties `[\"proj:epsg\"]` we also notice something strange, as the value is `float` and should be `integer`. We'll revise this using the code below, but it will be revised upstream in the future. " - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "items[0].properties[\"proj:epsg\"] = int(items[0].properties[\"proj:epsg\"])" + "Explore through the item's assets. We can see from the data's statistics values that the `min` and `max` values for the observed values range from `0` to `429` Mg ha-1." ] }, { @@ -273,29 +238,17 @@ }, { "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "# This is a workaround that is planning to move up into stackstac itself\n", - "\n", - "import boto3\n", - "import stackstac\n", - "import rasterio as rio\n", - "import rioxarray\n", - "\n", - "gdal_env = stackstac.DEFAULT_GDAL_ENV.updated(\n", - " always=dict(\n", - " AWS_NO_SIGN_REQUEST=True, session=rio.session.AWSSession(boto3.Session())\n", - " )\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": 8, + "execution_count": 6, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/srv/conda/envs/notebook/lib/python3.11/site-packages/stackstac/prepare.py:408: UserWarning: The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n", + " times = pd.to_datetime(\n" + ] + }, { "data": { "text/html": [ @@ -662,30 +615,30 @@ " stroke: currentColor;\n", " fill: currentColor;\n", "}\n", - "
<xarray.DataArray 'stackstac-486a109067eae0fbd2de23580e0f93f3' (time: 1,\n", + "<xarray.DataArray 'stackstac-52df0ce77b6e6dbb5f28f680fe94f581' (time: 1,\n", " band: 1,\n", " y: 81025,\n", - " x: 78078)>\n", + " x: 78078)> Size: 51GB\n", "dask.array<fetch_raster_window, shape=(1, 1, 81025, 78078), dtype=float64, chunksize=(1, 1, 1024, 1024), chunktype=numpy.ndarray>\n", "Coordinates: (12/16)\n", - " * time (time) datetime64[ns] NaT\n", - " id (time) <U19 'AGB_map_2017v0m_COG'\n", - " * band (band) <U11 'cog_default'\n", - " * x (x) float64 -18.27 -18.27 -18.27 ... 51.86 51.86 51.86\n", - " * y (y) float64 37.73 37.73 37.73 37.73 ... -35.05 -35.05 -35.05\n", - " proj:transform object {0.0, 1.0, 37.73103856358817, 0.000898315284119521...\n", + " * time (time) datetime64[ns] 8B NaT\n", + " id (time) <U19 76B 'AGB_map_2017v0m_COG'\n", + " * band (band) <U11 44B 'cog_default'\n", + " * x (x) float64 625kB -18.27 -18.27 -18.27 ... 51.86 51.86 51.86\n", + " * y (y) float64 648kB 37.73 37.73 37.73 ... -35.05 -35.05 -35.05\n", + " proj:bbox object 8B {-35.054059016911935, 51.86423292864056, 37.731...\n", " ... ...\n", - " proj:geometry object {'type': 'Polygon', 'coordinates': [[[-18.27352950...\n", - " proj:shape object {81024.0, 78077.0}\n", - " title <U17 'Default COG Layer'\n", - " description <U47 'Cloud optimized default layer to display on map'\n", - " raster:bands object {'scale': 1.0, 'nodata': 'inf', 'offset': 0.0, 'sa...\n", - " epsg int64 4326\n", + " proj:shape object 8B {81024, 78077}\n", + " start_datetime <U25 100B '2017-01-01T00:00:00+00:00'\n", + " raster:bands object 8B {'scale': 1, 'nodata': 'inf', 'offset': 0, 'sam...\n", + " title <U17 68B 'Default COG Layer'\n", + " description <U47 188B 'Cloud optimized default layer to display on map'\n", + " epsg int64 8B 4326\n", "Attributes:\n", " spec: RasterSpec(epsg=4326, bounds=(-18.274427824843425, -35.05405...\n", " crs: epsg:4326\n", " transform: | 0.00, 0.00,-18.27|\\n| 0.00,-0.00, 37.73|\\n| 0.00, 0.00, 1.00|\n", - " resolution: 0.0008983152841195214xarray.DataArray'stackstac-486a109067eae0fbd2de23580e0f93f3'
- time: 1
- band: 1
- y: 81025
- x: 78078
dask.array<chunksize=(1, 1, 1024, 1024), meta=np.ndarray>