statgis.gee.landsat_functions#

Function to process Landsat SR Images.

Module Contents#

Functions#

scaler(→ ee.Image)

Scale optical bands to surface reflectance values and thermal bands to Kelvin.

cloud_mask(→ ee.Image)

Mask pixels classified as clouds from QA_PIXEL band.

rename_bands(→ ee.Image)

Rename the bands from a Landsat Image.

statgis.gee.landsat_functions.scaler(image: ee.Image) ee.Image#

Scale optical bands to surface reflectance values and thermal bands to Kelvin.

Parameters:

image (ee.Image) – Landsat SR image.

Returns:

image – Image with bands scaled.

Return type:

ee.Image

Example

Scale an image:

>>> import ee
>>> from statgis.gee import landsat_functions
>>> ee.Initialize()
>>> poi = ee.Geometry.Point(-74.8180175, 10.9838119)
>>> image = (
...     ee.ImageCollection("LANDSAT/LC09/C02/T1_L2")
...     .filterBounds(poi)
...     .first()
... )
>>> image = landsat_functions.scaler(image)

Or scaler all image in a collection:

>>> import ee
>>> from statgis.gee import landsat_functions
>>> ee.Initialize()
>>> poi = ee.Geometry.Point(-74.8180175, 10.9838119)
>>> image_collection = (
...     ee.ImageCollection("LANDSAT/LC09/C02/T1_L2")
...     .filterBounds(poi)
...     .map(landsat_functions.scaler)
... )
statgis.gee.landsat_functions.cloud_mask(image: ee.Image, mask_snow: bool = False) ee.Image#

Mask pixels classified as clouds from QA_PIXEL band.

Parameters:
  • image (ee.Image) – Image to mask.

  • mask_snow (bool (optional)) – If True mask pixels classified as snow. If False mask only pixels classified as cloud.

Returns:

image – Masked image.

Return type:

ee.Image

Example

>>> import ee
>>> from statgis.gee import landsat_functions
>>> ee.Initialize()
>>> poi = ee.Geometry.Point(-74.8180175, 10.9838119)
>>> image = (
...     ee.ImageCollection("LANDSAT/LC09/C02/T1_L2")
...     .filterBounds(poi)
...     .first()
... )
>>> image = landsat_functions.cloud_mask(image)

On an image collection:

>>> import ee
>>> from statgis.gee import landsat_functions
>>> ee.Initialize()
>>> poi = ee.Geometry.Point(-74.8180175, 10.9838119)
>>> image_collection = (
...     ee.ImageCollection("LANDSAT/LC09/C02/T1_L2")
...     .filterBounds(poi)
...     .map(landsat_functions.cloud_mask)
... )
statgis.gee.landsat_functions.rename_bands(image: ee.Image) ee.Image#

Rename the bands from a Landsat Image.

Parameters:

image (ee.Image) – Image of interest.

Returns:

image – Image with bands renamed

Return type:

ee.Image

Example

Rename the bands in an image:

>>> import ee
>>> from statgis.gee import landsat_functions
>>> ee.Initialize()
>>> poi = ee.Geometry.Point(-74.8180175, 10.9838119)
>>> image = (
...     ee.ImageCollection("LANDSAT/LC09/C02/T1_L2")
...     .filterBounds(poi)
...     .first()
... )
>>> image = landsat_functions.rename_bands(image)

Also we can map the function to an image collection:

>>> import ee
>>> from statgis.gee import landsat_functions
>>> ee.Initialize()
>>> poi = ee.Geometry.Point(-74.8180175, 10.9838119)
>>> image_collection = (
...     ee.ImageCollection("LANDSAT/LC09/C02/T1_L2")
...     .filterBounds(poi)
...     .map(landsat_functions.rename_bands)
... )