Cloud Masking

Make all imports


In [ ]:
import ee
from geetools import ui, cloud_mask

Landsat 8 SR


In [ ]:
Map = ui.Map(tabs=('Inspector',))
Map.show()

In [ ]:
visL8 = {'bands':['B5','B6','B4'],'min':0, 'max':5000}
        
image = ee.Image('LANDSAT/LC08/C01/T1_SR/LC08_232090_20140915')
Map.addLayer(image, visL8, 'Landsat 8 SR Original')
Map.centerObject(image, zoom=12)

Using BQA band


In [ ]:
mask_l8SR_all = cloud_mask.landsatSR()
mask_l8SR_cloud = cloud_mask.landsatSR(['cloud'])
mask_l8SR_shadow = cloud_mask.landsatSR(['shadow'])
mask_l8SR_snow = cloud_mask.landsatSR(['snow'])

l8sr_masked_all = mask_l8SR_all(image)
l8sr_masked_cloud = mask_l8SR_cloud(image)
l8sr_masked_shadow = mask_l8SR_shadow(image)
l8sr_masked_snow = mask_l8SR_snow(image)

Map.addLayer(l8sr_masked_all, visL8, 'L8SR masked all')
Map.addLayer(l8sr_masked_cloud, visL8, 'L8SR masked cloud')
Map.addLayer(l8sr_masked_shadow, visL8, 'L8SR masked shadow')
Map.addLayer(l8sr_masked_snow, visL8, 'L8SR masked snow')

Landsat TOA


In [ ]:
MapTOA = ui.Map(tabs=('Inspector',))
MapTOA.show()

In [ ]:
visTOA = {'bands': visL8['bands'], 'min':0, 'max':0.5}
i_toa = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_232090_20140915')
MapTOA.addLayer(i_toa, visTOA, 'Landsat 8 TOA Original')
MapTOA.centerObject(i_toa, zoom=12)

Using BQA band


In [ ]:
mask_l8TOA_all = cloud_mask.landsat8TOA_BQA()
mask_l8TOA_cloud = cloud_mask.landsat8TOA_BQA(['cloud'])
mask_l8TOA_shadow = cloud_mask.landsat8TOA_BQA(['shadow'])
mask_l8TOA_snow = cloud_mask.landsat8TOA_BQA(['snow'])

l8toa_masked_all = mask_l8TOA_all(i_toa)
l8toa_masked_cloud = mask_l8TOA_cloud(i_toa)
l8toa_masked_shadow = mask_l8TOA_shadow(i_toa)
l8toa_masked_snow = mask_l8TOA_snow(i_toa)

MapTOA.addLayer(l8toa_masked_all, visTOA, 'L8TOA masked all')
MapTOA.addLayer(l8toa_masked_cloud, visTOA, 'L8TOA masked cloud')
MapTOA.addLayer(l8toa_masked_shadow, visTOA, 'L8TOA masked shadow')
MapTOA.addLayer(l8toa_masked_snow, visTOA, 'L8TOA masked snow')

Sentinel 2


In [ ]:
MapS2 = ui.Map(tabs=('Inspector',))
MapS2.show()

In [ ]:
visS2 = {'bands':['B8','B11','B4'],'min':0, 'max':5000}
is2 = ee.Image('COPERNICUS/S2/20151123T142942_20170221T180430_T18GYT')
MapS2.centerObject(is2, zoom=12)
MapS2.addLayer(is2, visS2, 'Sentinel 2 Original')

ESA Cloud Masking


In [ ]:
ESA_mask_all = cloud_mask.sentinel2()
is2_ESA = ESA_mask_all(is2)
MapS2.addLayer(is2_ESA, visS2, 'Sentinel 2 ESA maked')

Hollstein Decision Tree


In [ ]:
Hollstein_all = cloud_mask.hollstein_S2()
Hollstein_cloud = cloud_mask.hollstein_S2(['cloud'])
Hollstein_shadow = cloud_mask.hollstein_S2(['shadow'])
Hollstein_snow = cloud_mask.hollstein_S2(['snow'])
Hollstein_water = cloud_mask.hollstein_S2(['water'])
Hollstein_cirrus = cloud_mask.hollstein_S2(['cirrus'])

is2_Holl_all = Hollstein_all(is2)
is2_Holl_cloud = Hollstein_cloud(is2)
is2_Holl_shadow = Hollstein_shadow(is2)
is2_Holl_snow = Hollstein_snow(is2)
is2_Holl_water = Hollstein_water(is2)
is2_Holl_cirrus = Hollstein_cirrus(is2)

MapS2.addLayer(is2_Holl_all, visS2, 'Sentinel 2 Hollstein all')
MapS2.addLayer(is2_Holl_cloud, visS2, 'Sentinel 2 Hollstein cloud')
MapS2.addLayer(is2_Holl_shadow, visS2, 'Sentinel 2 Hollstein shadow')
MapS2.addLayer(is2_Holl_snow, visS2, 'Sentinel 2 Hollstein snow')
MapS2.addLayer(is2_Holl_water, visS2, 'Sentinel 2 Hollstein water')
MapS2.addLayer(is2_Holl_cirrus, visS2, 'Sentinel 2 Hollstein cirrus')

MODIS


In [ ]:
modis = ee.ImageCollection('MODIS/006/MOD09GA')

In [ ]:
MapMOD = ui.Map(tabs=('Inspector',))
MapMOD.show()

In [ ]:
site = ee.Geometry.Point([-71.8, -43])
date = ee.Date('2017-08-01')
visMOD = {'bands':['sur_refl_b02', 'sur_refl_b06', 'sur_refl_b01'],'min':0, 'max':5000}
modis = modis.filterDate(date, date.advance(4, 'month'))
i_mod = ee.Image(modis.first())
MapMOD.addLayer(i_mod, visMOD, 'MODIS TERRA Original Image')
MapMOD.centerObject(site, zoom=8)

Using state_1km band


In [ ]:
mod_mask = cloud_mask.modis09ga()
i_masked = mod_mask(i_mod)
MapMOD.addLayer(i_masked, visMOD, 'Masked MODIS')

In [ ]: