Skip to content

Commit

Permalink
Added details to the s-1 flood visualization script, making it compat…
Browse files Browse the repository at this point in the history
…ible with CDSE and adding explanation (#324)

* added copernicus browser and mosaic to s1 flood visualization

* additional text and image explaining use

* corrected evalscripturl

* added new figure

* requested changes implemented

* started page for S1 mosaics

* started editing custom sripts for Sentinel-1 mosaics

* Add s1 mosaic collection id to layout

* Automatic formatting of scripts

---------

Co-authored-by: chorng <[email protected]>
Co-authored-by: Jonas Viehweger <[email protected]>
  • Loading branch information
3 people authored Sep 9, 2024
1 parent 5822ea0 commit e367a11
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 2 deletions.
1 change: 1 addition & 0 deletions _layouts/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
S5_O3: S5_O3_CDAS
S5_SO2: S5_SO2_CDAS
S1_AWS_EW_HHHV: S1_CDAS_EW_HHHV
S1_MOSAIC: 3c662330-108b-4378-8899-525fd5a225cb
---

<h1 class="d-inline" id={{page.slug}}> {{page.title}} </h1>
Expand Down
42 changes: 40 additions & 2 deletions data-fusion/s1_flooding_visualisation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ parent: Data Fusion
layout: script
permalink: /data-fusion/s1_flooding_visualisation/
nav_exclude: true
scripts:
- [EO Browser, script.js]
- [Copernicus Browser, copernicus_browser.js]
- [Sentinel-2 mosaic, mosaic.js]
examples:
- zoom: '12'
lat: '51.98266'
lng: '-2.21409'
datasetId: S1GRD
fromTime: '2021-01-28T00:00:00.000Z'
toTime: '2021-01-28T23:59:59.999Z'
datasetId: S2L2A
fromTime: '2021-02-28T00:00:00.000Z'
toTime: '2021-02-28T23:59:59.999Z'
platform:
- CDSE
- EOB
evalscripturl: https://custom-scripts.sentinel-hub.com/custom-scripts/data-fusion/s1_flooding_visualisation/copernicus_browser.js

---


Expand All @@ -14,12 +33,31 @@ nav_exclude: true

## Evaluate and visualize
- [EO Browser](https://sentinelshare.page.link/i2yk)
- [Copernicus Browser](https://link.dataspace.copernicus.eu/2ufw)

## General description of the script

This script can be used to visualise flood events using Sentinel-1 GRD imagery. This is especially useful for areas of interest that are affected by cloud cover (common during flood events caused by excessive rainfall). The script uses a threshold of -15 decibels to classify flooded pixels. This value can be adjusted to suit your area of interest. In addition, to help the viewer orientate themselves, a clear Sentinel-2 image is used as the basemap for this visualisation so that it can be easily interpreted where the flood extent reaches for those unfamiliar with interpreting SAR images.
This script can be used to visualise flood events using Sentinel-1 GRD imagery. This is especially useful for areas of interest that are affected by cloud cover (common during flood events caused by excessive rainfall). The script uses a threshold of -15 decibels to classify flooded pixels. This value can be adjusted to suit your area of interest using the `lim` parameter. In addition, to help the viewer orientate themselves, a clear Sentinel-2 image is used as the basemap for this visualisation so that it can be easily interpreted where the flood extent reaches for those unfamiliar with interpreting SAR images.

### How to use

- Select your area of interest
- From Data Collections, select `Sentinel-2 Mosaic` or `Sentinel-2 L2A`. You can choose the most recent mosaic or the one from the same season as your time of interest; if you are selecting a single image, make sure it is cloud free.
- From Layers, select Custom Script. Click the Custom Script tab, and check the `Use additional datasets (advanced)` box. Under `Additional datasets`, you will see `S-1 GRD`. Click the `+` Sign to add it. Make sure you enable orthorectification. Optionally, you can also use a speckle filter.
- Check the `Customize timespan` box and select the timeframe you are interested in (the timeframe of your flood)
- Now paste the script in the code field. Take care to use the right one, `Copernicus Browser` if you are using a single Sentinel-2 image as a background and `Sentinel-2 Mosaic` if you want the mosaic background. Then click `Refresh Evalscript`.
- If you want to adjust the brightness of the background image, change the `f` constant. It is typically around 2.5 for Sentinel-2 images and 0.0008 for Sentinel-2 mosaics, increasing the gain makes the image brighter.

### Interpretation of results

Flooded areas will be marked in blue. Since this is a SAR dataset, the resulting map is affected by SAR speckle. In some cases, wet vegetation fields, steep slopes facing away from the sensor, or large flat surfaces such as airports can also create low backscatter and can thus be mistaken for flooded areas. Therefore, the 3D view can also be helpful for interpreting results: flooded areas are usually in the valley bottoms.

**Verification of flooding on a 3D image**
![Verification of flooding](fig/fig2.jpg)

## Description of representative images


In late 2023 and early 2024, north-western Europe experienced very high levels of rainfall, which led to widespread river flooding. This scene shows the Severn River upstream of Gloucester on 01 January 2024, with a Sentinel-2 image from 28 February 2024 as a background.

**Flooding in the UK 28th January 2021**
![flooding](fig/fig1.jpg)
36 changes: 36 additions & 0 deletions data-fusion/s1_flooding_visualisation/copernicus_browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//VERSION=3
function setup() {
return {
input: [
{
datasource: "S2L2A",
bands: ["B08"],
},
{
datasource: "S1GRD",
bands: ["VV", "dataMask"],
},
],
output: { bands: 4 },
mosaicking: "SIMPLE",
};
}

function toDB(input) {
return (10 * Math.log(input)) / Math.LN10;
}

//threshold value for water detection, reduce for more water, increase for less water
const lim = 15;
//gain value for image brightness (increase for brighter image)
const f = 2.5;

function evaluatePixel(sample) {
var S1 = sample.S1GRD[0];
var S2 = sample.S2L2A[0];
if (toDB(S1.VV) <= -1 * lim) {
return [S1.VV * 10, S1.VV * 10, S1.VV * 50, 1];
} else {
return [f * S2.B08, f * S2.B08, f * S2.B08, 1];
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions data-fusion/s1_flooding_visualisation/mosaic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//VERSION=3
function setup() {
return {
input: [
{
datasource: "CUSTOM",
bands: ["B02", "B03", "B04"],
},
{
datasource: "S1GRD",
bands: ["VV", "VH", "dataMask"],
},
],
output: { bands: 4 },
mosaicking: "SIMPLE",
};
}

function toDB(input) {
return (10 * Math.log(input)) / Math.LN10;
}
//threshold value for water detection, reduce for more water, increase for less water
const lim = 15;
//gain value for image brightness (increase for brighter image)
const f = 0.0008;

function evaluatePixel(sample) {
var S1 = sample.S1GRD[0];
var S2 = sample.CUSTOM[0];
if (toDB(S1.VV) <= -1 * lim) {
return [S1.VV * 10, S1.VV * 10, S1.VV * 50, 1];
} else {
return [f * S2.B04, f * S2.B03, f * S2.B02, 1];
}
}
30 changes: 30 additions & 0 deletions sentinel1-monthly-mosaic/rgb_ratio/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: RGB Ratio Script
parent: Sentinel-1
grand_parent: Sentinel
layout: script
permalink: /sentinel1-monthly-mosaic/rgb_ratio/
nav_exclude: true
examples:
- zoom: '11'
lat: '53.62774'
lng: '9.61716'
datasetId: S1_MOSAIC
fromTime: '2023-09-01T00:00:00.000Z'
toTime: '2023-09-01T23:59:59.999Z'
platform:
- CDSE
evalscripturl: https://custom-scripts.sentinel-hub.com/custom-scripts/sentinel1-monthly-mosaic/rgb_ratio/script.js
---

## Collection Access

[Sentinel-1 Monthly Mosaic](https://documentation.dataspace.copernicus.eu/APIs/SentinelHub/Data/S1GRD.html) is one of the [Sentinel-1 products](https://documentation.dataspace.copernicus.eu/Data/SentinelMissions/Sentinel1.html), that is offered in [Copernicus Data Space Ecosystem](https://dataspace.copernicus.eu/). The data is accessible via [Copernicus Browser](https://browser.dataspace.copernicus.eu/). To access the data, you need a [Copernicus Data Space Ecosystem account](https://documentation.dataspace.copernicus.eu/Registration.html), and then either create a [Sentinel Hub Process API request](https://documentation.dataspace.copernicus.eu/APIs/SentinelHub/Process.html) to the collection or to visualise the data via [Copernicus Browser](https://link.dataspace.copernicus.eu/h9t). The collection ID is `3c662330-108b-4378-8899-525fd5a225cb`.

[comment]: (and the collection type is `byoc-5460de54-082e-473a-b6ea-d5cbe3c17cca`.: # )

## General description of the script

This script combines the gamma0 of the VV and VH polarizations into a false color visualization. It uses the VV polarization in the red channel, the VH polarization in the green channel, and a ratio of VH/VV in the blue channel. It shows water areas in dark red (black), urban areas in yellow, vegetated areas in turquoise, and bare ground in dark purple.

For snowy and icy areas, the visualization can vary from light yellow to blue to red. In order not to confuse cryogenic features with non-cryogenic ones, some general information about the location is helpful in interpreting the image.
24 changes: 24 additions & 0 deletions sentinel1-monthly-mosaic/rgb_ratio/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//VERSION=3
function setup() {
return {
input: ["VV", "VH", "dataMask"],
output: { bands: 3 },
};
}

var viz = new HighlightCompressVisualizer(0, 0.8);
var gain = 0.8;

function evaluatePixel(sample) {
if (sample.dataMask == 0) {
return [0, 0, 0];
}

let vals = [
(gain * sample.VV) / 0.28,
(gain * sample.VH) / 0.06,
(gain * sample.VH) / sample.VV / 0.49,
];

return viz.processList(vals);
}
21 changes: 21 additions & 0 deletions sentinel1-monthly-mosaic/sentinel1-monthly-mosaic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
layout: default
title: Sentinel-1 Monthly Mosaic
nav_order: 5
parent: Sentinel
permalink: /sentinel/sentinel1-monthly-mosaic/
---

# Sentinel-1 Monthly Mosaic

Sentinel-1 Monthly mosaics are an analysis-ready product of individual Sentinel-1 acquisitions. The dataset is prepared for most populated areas of the world. Two separate data products are available: Sentinel-1 IW Monthly Mosaics for the temperate zone and the tropics with VV and VH polarization, and Sentinel-1 DH Monthly Mosaics with HH and HV polarization for the polar regions. The resolution of the collection is 20 meters.

The algorithm used to derive the product was run independently at pixel level. For each pixel and each band, a weighted average of the pixel values was calculated. The weights were calculated based on the local resolution (the inverse of the imaged area) that particular pixel. The imaged area is a function of the sensor configuration (look angle and azimuth) and the local terrain aspect and slope. If the slope is facing towards the sensor, the imaged area is small and returned intensity will be high, while if it is facing away from the sensor, the the imaged area is large and the returned intensity will be low or even zero for radar shadows.
For more details of this correction process, visit [(Small 2012)](https://ieeexplore.ieee.org/abstract/document/6350465).

Please find related resources and more information about the collection [here](https://documentation.dataspace.copernicus.eu/APIs/SentinelHub/Data/S1GRD.html#processing-chain).

- [RGB ratio](/sentinel1-monthly-mosaic/rgb_ratio)
- [False Color](/sentinel2-quarterly-cloudless-mosaic/false-color)
- [NDVI](/sentinel2-quarterly-cloudless-mosaic/ndvi)
- [NDWI](/sentinel2-quarterly-cloudless-mosaic/ndwi)

0 comments on commit e367a11

Please sign in to comment.