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

Ship detection with Sentinel-1 and Sentinel-2

//VERSION=3
//Ship detection with S1 and S2
//Author: Monja B. Šebela

function setup() {
  return {
    input: [
      { datasource: "S2L1C", bands: ["B02", "B03", "B04", "B08"], mosaicking: "ORBIT" },
      { datasource: "S1GRD", bands: ["VV", "VH"], mosaicking: "ORBIT" }
    ],
    output: [
      { id: "default", bands: 3, sampleType: SampleType.AUTO }
    ]
  };
}

function evaluatePixel(samples) {
  var S2L1C = samples.S2L1C[0]
  var S1 = samples.S1GRD[0]
  let ndwi = (S2L1C.B03 - S2L1C.B08) / (S2L1C.B03 + S2L1C.B08)

  if ((ndwi > 0.1) && ((S1.VV > 0.3) || (S1.VH > 0.3))) {
    return {
      default: [1, 1, 1]
    }
  }
  else if (ndwi > 0.1) {
    return {
      default: [(4 * S2L1C.B04) - 0.2, (4 * S2L1C.B03) - 0.2, (5 * S2L1C.B02) - 0.2]
    }
  }

  let val = [(4 * S2L1C.B04) - 0.2, (4 * S2L1C.B03) - 0.2, (4 * S2L1C.B02) - 0.2];
  return {
    default: val
  }
}

Author:

Monja B. Šebela

Evaluate and visualize

General description of the script

This script masks water areas using Sentinel-2 NDWI, and returns the high NDWI pixels, which also highly reflect VV and VH polarizations, in white, displaying ships. The script tends to overestimate in narrow water corridors, over bridges, and it has cross-like artefacts where pixels are extremely reflective. It often underestimates ships of red color. It can be useful to generally estimate ship traffic density.

Description of representative images

Ship traffic of Yangtze river, at Zhenjiang and Yangzhong, China ships