earthlib.CloudMask
Functions for cloud masking earth engine images.
Landsat4578(img)
¶
Cloud-masks Landsat images.
See gis.stackexchange.com/questions/349371/creating-cloud-free-images-out-of-a-mod09a1-modis-image-in-gee Previously: gis.stackexchange.com/questions/425159/how-to-make-a-cloud-free-composite-for-landsat-8-collection-2-surface-reflectanc/425160
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img |
Image
|
the ee.Image to mask. Must have a Landsat "QA_PIXEL" band. |
required |
Returns:
Type | Description |
---|---|
Image
|
the same input image with an updated mask. |
Source code in earthlib/CloudMask.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
MODIS(img)
¶
Dummy function for MODIS images.
This function just returns the original image because the MODIS collection already applies a cloud mask to all pixels. It only exists so as to not break other processing chains that use .bySensor() methods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img |
Image
|
an ee.Image. |
required |
Returns:
Type | Description |
---|---|
Image
|
the input image. |
Source code in earthlib/CloudMask.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
Opening(img, iterations=3)
¶
Apply a morphological opening filter to an image mask.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img |
Image
|
the ee.Image to mask. Must have a mask band set. |
required |
iterations |
int
|
the number of sequential dilate/erode operations. |
3
|
Returns:
Type | Description |
---|---|
Image
|
the input image with an updated, opened mask. |
Source code in earthlib/CloudMask.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
Sentinel2(img, use_qa=True, use_scl=True)
¶
Mask Sentinel2 images using multiple masking approaches.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img |
Image
|
the ee.Image to mask. |
required |
use_qa |
bool
|
apply QA band cloud masking. img must have a "QA60" band. |
True
|
use_scl |
bool
|
apply SCL band cloud masking. img must have a "SCL" band. |
True
|
Returns:
Type | Description |
---|---|
Image
|
the same input image with an updated mask. |
Source code in earthlib/CloudMask.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
Sentinel2QA(img)
¶
Masks Sentinel2 images using the QA band.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img |
Image
|
the ee.Image to mask. Must have a Sentinel "QA60" band. |
required |
Returns:
Type | Description |
---|---|
Image
|
the same input image with an updated mask. |
Source code in earthlib/CloudMask.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
Sentinel2SCL(img)
¶
Masks Sentinel2 images using scene classification labels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img |
Image
|
the ee.Image to mask. Must have a Sentinel "SCL" class band. |
required |
Returns:
Type | Description |
---|---|
Image
|
the same input image with an updated mask. |
Source code in earthlib/CloudMask.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
VIIRS(img)
¶
Masks VIIRS images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img |
Image
|
the ee.Image to mask. Must have "QF1" and "QF2" bands. |
required |
Returns:
Type | Description |
---|---|
Image
|
the same input image with an updated mask. |
Source code in earthlib/CloudMask.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
bitwiseSelect(img, fromBit, toBit=None)
¶
Filter QA bit masks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img |
Image
|
the QA band image |
required |
fromBit |
int
|
QA start bit |
required |
toBit |
int
|
QA end bit |
None
|
Returns:
Type | Description |
---|---|
Image
|
encoded bitmap for the passed QA bits |
Source code in earthlib/CloudMask.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
bySensor(sensor)
¶
Returns the appropriate cloud mask function to use by sensor type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor |
str
|
string with the sensor name to return (e.g. "Landsat8", "Sentinel2"). |
required |
Returns:
Type | Description |
---|---|
Callable
|
the mask function associated with a sensor to pass to an ee .map() call |
Source code in earthlib/CloudMask.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|