From 0c4268d2db43ef7888e1d79f482ad0ee0fb89787 Mon Sep 17 00:00:00 2001 From: Alex Bradley <55119000+abradley60@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:36:13 +0930 Subject: [PATCH] adding global SAR access through microsoft planetary compute (#1263) * adding global SAR access through microsoft planetary compute * Make minor spelling and formatting amendments. * small changes for PR --------- Co-authored-by: geoscience-aman <96451725+geoscience-aman@users.noreply.github.com> --- .../Radar_water_detection.ipynb | 645 +++++++++++++++++- 1 file changed, 643 insertions(+), 2 deletions(-) diff --git a/Real_world_examples/Radar_water_detection.ipynb b/Real_world_examples/Radar_water_detection.ipynb index c69d37bb..01d0669e 100644 --- a/Real_world_examples/Radar_water_detection.ipynb +++ b/Real_world_examples/Radar_water_detection.ipynb @@ -2309,11 +2309,652 @@ "metadata": {}, "source": [ "## Next steps\n", + "\n", + "### 1. Select another Australian area using DEA Data\n", + "\n", "When you are done, return to the \"Analysis parameters\" section, modify some values (e.g. `latitude` and `longitude`) and rerun the analysis.\n", "You can use the interactive map in the \"View the selected location\" section to find new central latitude and longitude values by panning and zooming, and then clicking on the area you wish to extract location values for.\n", - "You can also use Google maps to search for a location you know, then return the latitude and longitude values by clicking the map.\n", + "You can also use Google maps to search for a location you know, then retrieve the latitude and longitude values by clicking the map.\n", + "\n", + "If you're going to change the location, you'll need to make sure Sentinel-1 data is available for the new location, which you can check on the [DEA Explorer](https://explorer.dea.ga.gov.au/products/s1_gamma0_geotif_scene)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 2. Investigate Global Areas (excl. Antarctica) using Microsoft Planetary Computer Data\n", + "\n", + "Currently, the DEA datacube has a limited amount of analysis-ready Sentinel-1 data. To extend our analysis to other areas of the globe, we are able to make use of the [Microsoft's Planetary Computer](https://planetarycomputer.microsoft.com/) catalog of satellite and environmental data.\n", + "This data is accompanied by detailed [SpatioTemporal Asset Catalog (STAC)](https://stacspec.org/en) metadata, which makes it possible to search and discover data from specific products, time periods and locations of interest.\n", + "\n", + "See more about combining Microsoft Planetary Compute data and DEA data here: [Planetary_computer.ipynb](../How_to_guides/Planetary_computer.ipynb)\n", + "\n", + "See more about the Sentinel-1-RTC product here: https://planetarycomputer.microsoft.com/dataset/sentinel-1-rtc" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Import extra libraries\n", + "import pystac_client\n", + "import planetary_computer\n", + "\n", + "import odc.stac\n", + "import odc.geo.xr\n", + "from odc.geo.geom import BoundingBox" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# this is the same as the top of the notebook, \n", + "# but we can change to other areas of interest\n", + "latitude = (-11.288, -11.086)\n", + "longitude = (130.324, 130.453)\n", + "time = (\"2020-01\", \"2020-02\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Open a client pointing to the Microsoft Planetary Computer data catalogue\n", + "catalog = pystac_client.Client.open(\n", + " \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n", + " modifier=planetary_computer.sign_inplace,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Found 5 STAC items\n" + ] + } + ], + "source": [ + "# Convert data-cube style queries into something readable by `pystac_client`\n", + "bbox = BoundingBox.from_xy(longitude, latitude)\n", + "time_range = \"/\".join(time)\n", + "\n", + "# Search for STAC items from \"esa-worldcover\" product\n", + "search = catalog.search(\n", + " collections=\"sentinel-1-rtc\",\n", + " bbox=bbox,\n", + " datetime=time_range,\n", + ")\n", + "\n", + "# Check how many items were returned\n", + "items = search.item_collection()\n", + "print(f\"Found {len(items)} STAC items\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Loading data using `odc-stac`\n", + "\n", + "Once we have found some data, we can load it into our notebook using the [odc-stac](https://odc-stac.readthedocs.io/en/latest/?badge=latest) Python library.\n", + "The `odc.stac.load` function works similarly to `dc.load`, allowing us to load one or more bands of data into an `xarray.Dataset()`.\n", + "\n", + "Here we will load sentinel-1 RTC data for our study area into Australian Albers 20 m pixels.\n", + "\n", + "> **Note:** The `odc.stac.load` function uses slightly different terminology to `dc.load`, for example: \"bands\" vs \"measurements\", \"groupby\" vs \"group_by\", \"chunks\" vs \"dask_chunks\"." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
<xarray.Dataset> Size: 32MB\n", + "Dimensions: (y: 1102, x: 736, time: 5)\n", + "Coordinates:\n", + " * y (y) float64 9kB -1.166e+06 -1.166e+06 ... -1.188e+06 -1.188e+06\n", + " * x (x) float64 6kB -1.874e+05 -1.874e+05 ... -1.728e+05 -1.727e+05\n", + " spatial_ref int32 4B 3577\n", + " * time (time) datetime64[ns] 40B 2020-01-10T20:56:36.059834 ... 202...\n", + "Data variables:\n", + " vh (time, y, x) float32 16MB 0.003807 0.004765 ... 0.03516 0.07016\n", + " vv (time, y, x) float32 16MB 0.03688 0.04085 ... 0.1356 0.1253