Skip to main content Link Menu Expand (external link) Document Search Copy Copied

White-Water Detection Script

//VERSION=3 (auto-converted from 1)

/*
Author: Mohor Gartner (Linkedin: https://www.linkedin.com/in/mohor-gartner/)
*/

// setup values

function setup() {
	return {
		input: [{
			bands: [
				"B02",
				"B03",
				"B04",
				"B08",
				"B8A",
				"B10",
				"B11",
				"B12"
			]
		}],
		output: { bands: 3 },
		mosaicking: "ORBIT"
	}
}


// change colour if needed

function colourChange(currC, newC) {
	if (newC > currC) {
		return newC;
	} else {
		return currC;
	}
}

// evaluate pixel

function evaluatePixel(pix) {
	//value to store for every pixel in choosen timeline if it is a white-water. 0->not white-water; 1->white-water; 2-white-water

	let WW = 0;
	// store bands for white water 

	let B04ww = 0;
	let B03ww = 0;
	let B02ww = 0;
	//store bands for RGB with no white-water

	let B04nat = 0;
	let B03nat = 0;
	let B02nat = 0;

	// loop through timeline

	for (var i = 0; i < pix.length; i++) {
		//simplify band values variables

		let B02 = pix[i].B02;
		let B03 = pix[i].B03;
		let B04 = pix[i].B04;
		let B08 = pix[i].B08;
		let B8A = pix[i].B8A;
		let B10 = pix[i].B10;
		let B11 = pix[i].B11;
		let B12 = pix[i].B12;

		//// calculate indices

		//ndwi, not needed

		//let ndwi=(B03-B08)/(B03+B08);

		//moisture index

		let moist = (B8A - B11) / (B8A + B11);
		//NDSI

		let ndsi = (B03 - B11) / (B03 + B11); //>0.42 should be snowy

		//NDVI

		let ndvi = (B08 - B04) / (B08 + B04);

		// change maximum white-water value if necessary -> it is needed to store for composite white-water detection

		let WWi = (ndsi >= 0.5 && moist >= 0.4 && ndvi <= 0.2 && B10 < 0.015 && B12 < 0.2 && B11 <= 0.4 && B04 > 0.2)
			? (ndsi <= 0.63 && B11 <= 0.17 && B04 >= 0.35)
				? 2
				: 1
			: 0;

		//// take for RGB. Mosaic order should be Least cloud coverage. Therefore non white-water pixels have non cloud coverage.

		//there are some errors/empty pixels, where all RGB are 0

		//

		if (B04 != 0 && B03 != 0 && B02 != 0) {
			B04nat = B04;
			B03nat = B03;
			B02nat = B02;
		}

		// change WW max if white water detected and higher level than before

		if (WWi >= WW) {
			WW = WWi;
			B04ww = colourChange(B04ww, B04);
			B03ww = colourChange(B03ww, B03);
			B02ww = colourChange(B02ww, B02);
		}

	}

	//visualization parameters

	let gain = 1.5;
	let gain1 = 2;
	let gain2 = 2.5;

	// set the output colours

	let RGB = [B04nat, B03nat, B02nat].map(a => gain * a);
	let RGBww1 = [B04ww, B03ww * gain1, 0.25];
	let RGBww2 = [B04ww / 4, B03ww / 3, B02ww].map(a => gain2 * a);

	// sets colours according to multi-temporal composite

	if (WW == 2) return RGBww2;
	else if (WW == 1) return RGBww1;
	else return RGB;
}

Evaluate and Visualize

General description of the script

The script can be used for mapping white-water zones. Primary, the focus is on detection of white-water on the coastline (surf zone). Secondly, it can be also used for the detection of white-water on rivers. The most useful way to analyze white-water zones is with multi-temporal analysis. Nevertheless, it can be used also directly on one image.

White-water mapping is beneficial in different areas: improvement of bathymetric mapping from multi-temporal analysis of Sentinel 2 data (Evagorou et. al., 2019), erosion level evaluation, identification of reef or submerged reef, bathymetry slope evaluation, civil engineering (potential location for new ports, coastal protection structures and measures), maritime navigation, wave hydrodynamics (swell direction etc.), surf zone habitat identification, wave breaking numerical modeling validation, detection of new reef or island, wind conditions detection, ships location, new surf spots identification. There are also 3 alternative ways to use this custom script: detection of white-water on rivers, a rise of the sea level, snow and ice detection.

Applicability of the script

The script is globally applicable on coastal zones in case of coastal white-water detection. It is even applicable in low waves conditions (Adriatic, Mediterranean). If snow, ice, and white-water are all present, the script is not able to differentiate between them.

In the case of white-water detection on rivers, the script is applicable to bigger and wider rivers, where no snow and ice are present. In addition, the river should not have a higher amount of floating sediment.

In case of snow and ice detection, the script is applicable on snowy and ice zones, except on high-altitude terrain.

The script works the best while no clouds are present. Nevertheless, higher waves and wider white-water zones could be detected with the presence of clouds.

False detection problems

In cloudy conditions, script can falsely detect cloud as white-water. Also for river in area with snow and ice coverage, everything is defined as white-water.

In some cases, shallow coastal waters with bright colour bed can be falsely detected as white-water.

How the script works

The script on white-water detection is based on a statistical analysis of 13 bands and different indices (NDSI, NDWI, NDVI, moisture) with manual calibration. The first level of detection are limits for indices/bands: NDSI (land/water), moisture index, NDVI (land/water, correction of false detection of white-water on land), B10 (cirrus, high-altitude), B11, B12. The second level for a higher probability of white-water zones is done with stricter limits on some already used indices/bands.

Additional explanation on benefits of white-water mapping and on how the script works is awailable in supplementary material.

Author of the script

Mohor Gartner

Description of representative images

  1. Nazare (Portugal)

Nazare (Portugal) NazarÈ (Portugal) is very well known for the highest wave ever surfed (well at least among surfers). With the script, the location was analyzed with multi-temporal mosaic from 1.7.2015 to 16.4.2019 (maximum 5% cloud coverage, mosaic order: Least cloud coverage). It is very clear, that north beach is exposed to higher waves as the white-water zone is very wide. Therefore, erosion potential is higher and waves are likely higher. It seems that port is well protected by waves, as no white-water was detected inside the port bay. In addition, we can see, that the location of the entrance port is also good as it is in the south part of the beach where the white-water zone is less wide. Away from the coastline, we can also see the detection of some white-water. This white-water is probably caused by high winds, which can cause wave breaking without the impact of the shallow sea bed. We can also conclude that habitat for plants and animals can be quite intensive in variable in the wide zone of the north beach.

  1. Victoria Falls (Zimbabwe)

Victoria Falls (Zimbabwe) Victoria Falls (Zimbabwe) is one of the biggest waterfalls in the world. With the script, the location was analyzed with multi-temporal mosaic from 1.7.2015 to 16.4.2019 (maximum 10% cloud coverage, mosaic order: Least cloud coverage). We can clearly identify the location of the fall, as all area with white-water is detected for the highest recorded flow in the period with Sentinel data. In addition, downstream the waterfall, there are also other locations with white-water. Therefore, we identified locations on the river with the highest erosion potential and presumably highest inclination of the river bed for the observed area.

  1. West of Hˆfn (Iceland)

West of Hˆfn (Iceland) Wider is west of Hˆfn (Iceland) was analyzed with the script for 23.3.2018. On the water, the script clearly detects white-water close zone to the coastline and a bit away from the coastline, which implies (submerged) reef. On the land, areas with snow/ice coverage are detected. Only areas in the shadow are not detected.

  1. Fierry Cross Reef (South China Sea)

Fierry Cross Reef (South China Sea) China had built artificial islands in the South China Sea. With the script, we can identify if the location of the artificial island is suitable regarding water hydrodynamic. Location was analyzed with multi-temporal mosaic from 12.9.2015 to 18.4.2019 (maximum 25% cloud coverage, mosaic order: Least cloud coverage). We can notice, that white-water zone has some offset from the coastline. Therefore we can assume that there is submerged reef (natural or artificial submerged breakwater). White-water zone is wider on the northwest and west side of the island. We can assume that swell/waves from that direction are higher. In addition, potential erosion and run-up of the waves are also higher than on the northeast, east and southeast part of the island. Selection of port entrance on the northeast side is therefore appropriate. In addition, the port is even more protected from high wave on the northwest side with a wider strip of land. In case that submerged reef is artificial, that changed habitat for plants and animals. Also timelapse was tested for the area. It can be seen, that in some cases white-water zone is presented, but not detected by the script as cirrus clouds prevent that detection.

  1. Limassol (Cyprus)

Limassol (Cyprus) Bathymetric map from multi-temporal analysis of Sentinel-2 data (Evagorou et al., 2019) processed 12 satellite images one for each month from 4.4.2017 to 18.2.2018. With the script, time-lapse animation was done for the later period (cloud coverage under 57%) on the east side of the study site. For satellite image on 19.1.2018, custom script clearly detects white-water zone. The later image is a basis from one of twelve images for mapping bathymetry (Evagorou et al., 2019). Therefore, with custom script detection of white-water, the study could exclude the later image as it was identified that the quality of the bathymetry map could be affected by sea state (waves). In the mentioned period there are some other dates with white-water zone detection, which are not included in the study (14.4.2017, 6.9.2017, 25.12.2017, 4.1.2018). In addition, we can see that custom script is also applicable in case of low waves in the Mediterranean Sea.

Supplementary material (PDF) includes other examples of custom script analysis for individual images.

References

Some theory/projects, which support usefulness of white-water custom script:

Credits

Template script to make multi-temporal processing was used from NDVI script.