Skip to content

Commit

Permalink
remove small isolated clouds before shadow projection for S2
Browse files Browse the repository at this point in the history
  • Loading branch information
dugalh committed Oct 29, 2021
1 parent 411b16c commit 2614714
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions geedim/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,15 @@ def _get_image_masks(self, ee_image):
shadow_azimuth = ee.Number(-90).add(ee.Number(ee_image.get("MEAN_SOLAR_AZIMUTH_ANGLE")))
min_scale = get_projection(ee_image).nominalScale()

# project the the cloud mask in the direction of sun's rays
# remove small clouds
cloud_mask_open = (
cloud_mask.focal_min(self._buffer, "circle", "meters").focal_max(self._buffer, "circle", "meters")
)

# project the opened cloud mask in the direction of sun's rays (i.e. shadows)
proj_dist_pix = ee.Number(self._cloud_proj_dist * 1000).divide(min_scale) # projection distance in pixels
proj_cloud_mask = (
cloud_mask.directionalDistanceTransform(shadow_azimuth, proj_dist_pix)
cloud_mask_open.directionalDistanceTransform(shadow_azimuth, proj_dist_pix)
.select("distance")
.mask()
.rename("PROJ_CLOUD_MASK")
Expand Down
2 changes: 1 addition & 1 deletion geedim/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.3.0'
__version__ = '0.3.1'

0 comments on commit 2614714

Please sign in to comment.