r-earthengine / ee_extra

A ninja python package that unifies the Google Earth Engine ecosystem.
https://ee-extra.readthedocs.io/
Other
58 stars 10 forks source link

added cloud_score+ #48

Open Spiruel opened 8 months ago

Spiruel commented 8 months ago

A new cloud mask has been added to GEE. It'd be great to get this added to ee_extra, and therefore eemont.

This makes use of .linkCollection() which is available in the latest version of earthengine-api ('0.1.377'). I was unsure whether it was worth editing the cloud_prob code to use this new method as well. I've left it alone for now.

Here's some code to compare cloud_prob to cloud_score+:

"""#cloud score.ipynb

import geemap

import eemont
import ee

#ee.Authenticate()
ee.Initialize()

col = ee.ImageCollection('COPERNICUS/S2_SR')

S2 = ee.ImageCollection('COPERNICUS/S2_SR')

point = ee.Geometry.Point(-2.82,54.04)

date = '2023-04-01'
prob = 50

img = S2.filterBounds(point).closest(date).maskClouds(method='cloud_prob', prob=prob)

img2 = S2.filterBounds(point).closest(date).maskClouds(method='cloud_score+', prob=prob)

viz = {'bands':['B4','B3','B2'], 'min':0,'max':5000}

Map = geemap.Map(center=(54.04,-2.82), zoom=12, height=600)

cloud_prob = geemap.ee_tile_layer(img, viz, 'cloud_prob')
cloud_score = geemap.ee_tile_layer(img2, viz, 'cloud_score+')
Map.split_map(cloud_prob, cloud_score)

Map.add_text(f'cloud_prob {prob}%', position='topleft')
Map.add_text(f'cloud_score+ {prob}%', position='topright')
Map

@davemlz, @csaybar, @aazuspan @KMarkert