Skip to content

Commit

Permalink
Return False, None if the mask for a certain tile contains no valid p…
Browse files Browse the repository at this point in the history
…ixels.
  • Loading branch information
daviddemeij committed Mar 15, 2022
1 parent 42dec23 commit 83acc2e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions s2p/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ def is_this_tile_useful(x, y, w, h, images_sizes):
wat_msk = cfg['images'][0]['wat']
mask = masking.image_tile_mask(x, y, w, h, roi_msk, cld_msk, wat_msk,
images_sizes[0], cfg['border_margin'])
if not mask.any():
return False, None
return True, mask


Expand Down
2 changes: 2 additions & 0 deletions s2p/masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def image_tile_mask(x, y, w, h, roi_gml=None, cld_gml=None, raster_mask=None,
with rasterio.open(raster_mask, 'r') as f:
mask = np.logical_and(mask, f.read(window=((y, y+h), (x, x+w)),
boundless=True).squeeze())
if not mask.any():
return mask

# image borders mask
if img_shape is not None:
Expand Down

0 comments on commit 83acc2e

Please sign in to comment.