Google Earth Engine – Masking Out Shadows in Sentinel Images Using GEE

cloud covergoogle-earth-engine

This question is an addition to this answer to Creating Sentinel-2 cloud free, cloud-shadow free composite or scene on Google Earth Engine (GEE)?

There Rodrigo E. Principe showed how to mask out the clouds. I am wondering if there is a way to mask the shadows as well. And, if possible then not only the shadows of the clouds but also, shadows in rugged topography.

Best Answer

There has been an approach to do this using a decision tree: Ready-to-Use Methods for the Detection of Clouds, Cirrus, Snow, Shadow, Water and Clear Sky Pixels in Sentinel-2 MSI Images.

I have adapted the code to EE, and make it open source in geetools, both for the Python API and for the JavaScript API

var cld = require('users/fitoprincipe/geetools:cloud_masks')
var image = ee.Image('COPERNICUS/S2/20151123T142942_20170221T180430_T19GCN')

Map.centerObject(image)

var mask_shadow = cld.hollstein_S2(['shadow'])(image)

Map.addLayer(mask_shadow, {bands:['B8', 'B11','B4'], min:0, max:5000})
Related Question