LandsatCollection Documentation

class RadGEEToolbox.LandsatCollection.LandsatCollection(start_date=None, end_date=None, tile_row=None, tile_path=None, cloud_percentage_threshold=None, boundary=None, collection=None)

Class object representing a combined collection of NASA/USGS Landsat 5, 8, and 9 TM & OLI surface reflectance satellite images at 30 m/px

This class provides methods to filter, process, and analyze Landsat satellite imagery for a given period and region

Arguments:

start_date (str): Start date string in format of yyyy-mm-dd for filtering collection (required unless collection is provided)

end_date (str): End date string in format of yyyy-mm-dd for filtering collection (required unless collection is provided)

tile_row (int or list): WRS-2 tile row of Landsat image (required unless boundary or collection is provided) - see https://www.usgs.gov/landsat-missions/landsat-shapefiles-and-kml-files

tile_path (int or list): WRS-2 tile path of Landsat image (required unless boundary or collection is provided) - see https://www.usgs.gov/landsat-missions/landsat-shapefiles-and-kml-files

cloud_percentage_threshold (int): Integer percentage threshold where only imagery with cloud % less than threshold will be provided (defaults to 100)

boundary (ee.Geometry): Boundary for filtering images to images that intersect with the boundary shape (optional) - will override tile specifications

collection (ee.ImageCollection): Optional argument to provide an ee.ImageCollection object to be converted to a LandsatCollection object - will override other arguments!

Attributes:

collection: Returns an ee.ImageCollection object from any LandsatCollection image collection object

_dates_list: Cache storage for dates_list property attribute

_dates: Cahce storgage for dates property attribute

ndwi_threshold: Default threshold for masking ndwi imagery

ndvi_threshold: Default threshold for masking ndvi imagery

halite_threshold: Default threshold for masking halite imagery

gypsum_threshold: Default threshold for masking gypsum imagery

turbidity_threshold: Default threshold for masking turbidity imagery

chlorophyll_threshold: Default threshold for masking chlorophyll imagery

_masked_clouds_collection: Cache storage for masked_clouds_collection property attribute

_masked_water_collection: Cache storage for masked_water_collection property attribute

_masked_to_water_collection: Cache storage for masked_to_water_collection property attribute

_geometry_masked_collection: Cache storage for mask_to_polygon method

_geometry_masked_out_collection: Cache storage for mask_out_polygon method

_median: Cache storage for median property attribute

_mean: Cache storage for mean property attribute

_max: Cache storage for max property attribute

_min: Cache storage for min property attribute

_ndwi: Cache storage for ndwi property attribute

_ndvi: Cache storage for ndvi property attribute

_halite: Cache storage for halite property attribute

_gypsum: Cache storage for gypsum property attribute

_turbidity: Cache storage for turbidity property attribute

_chlorophyll: Cache storage for chlorophyll property attribute

_LST: Cache storage for LST property attribute

_MosaicByDate: Cache storage for MosaicByDate property attribute

Property attributes:

dates_list (returns: Server-Side List): Unreadable Earth Engine list of image dates (server-side)

dates (returns: Client-Side List): Readable pythonic list of image dates (client-side)

masked_clouds_collection (returns: LandsatCollection image collection): Returns collection with clouds masked (transparent) for each image

masked_water_collection (returns: LandsatCollection image collection): Returns collection with water pixels masked (transparent) for each image

masked_to_water_collection (returns: LandsatCollection image collection): Returns collection with pixels masked to water (transparent) for each image (masks land and cloud pixels)

max (returns: ee.Image): Returns a temporally reduced max image (calculates max at each pixel)

median (returns: ee.Image): Returns a temporally reduced median image (calculates median at each pixel)

mean (returns: ee.Image): Returns a temporally reduced mean image (calculates mean at each pixel)

min (returns: ee.Image): Returns a temporally reduced min image (calculates min at each pixel)

MosaicByDate (returns: LandsatCollection image collection): Mosaics image collection where images with the same date are mosaiced into the same image. Calculates total cloud percentage for subsequent filtering of cloudy mosaics.

gypsum (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband gypsum index rasters

halite (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband halite index rasters

LST (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband land-surface-temperature rasters (Celcius)

ndwi (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband NDWI (water) rasters

ndvi (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband NDVI (vegetation) rasters

turbidity (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband NDTI (turbidity) rasters

chlorophyll (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband KIVU (relative chlorophyll-a) rasters

Methods:

get_filtered_collection(self)

get_boundary_filtered_collection(self)

ndwi_collection(self, threshold, ng_threshold=None)

ndvi_collection(self, threshold, ng_threshold=None)

halite_collection(self, threshold, ng_threshold=None)

gypsum_collection(self, threshold, ng_threshold=None)

turbidity_collection(self, threshold, ng_threshold=None)

chlorophyll_collection(self, threshold, ng_threshold=None)

masked_water_collection_NDWI(self, threshold)

masked_to_water_collection_NDWI(self, threshold)

surface_temperature_collection(self)

mask_to_polygon(self, polygon)

mask_out_polygon(self, polygon)

mask_halite(self, threshold, ng_threshold=None)

mask_halite_and_gypsum(self, halite_threshold, gypsum_threshold, halite_ng_threshold=None, gypsum_ng_threshold=None)

PixelAreaSumCollection(self, band_name, geometry, threshold, scale, maxPixels)

image_grab(self, img_selector)

custom_image_grab(self, img_col, img_selector)

image_pick(self, img_date)

CollectionStitch(self, img_col2)

Static Methods:

image_dater(image)

landsat5bandrename(img)

landsat_ndwi_fn(image, threshold, ng_threshold=None)

landsat_ndvi_fn(image, threshold, ng_threshold=None)

landsat_halite_fn(image, threshold, ng_threshold=None)

landsat_gypsum_fn(image, threshold, ng_threshold=None)

landsat_ndti_fn(image, threshold, ng_threshold=None)

landsat_kivu_chla_fn(image, threshold, ng_threshold=None)

MaskWaterLandsat(image)

MaskToWaterLandsat(image)

MaskWaterLandsatByNDWI(image, threshold, ng_threshold=None)

MaskToWaterLandsatByNDWI(image, threshold, ng_threshold=None)

halite_mask(image, threshold, ng_threshold=None)

gypsum_and_halite_mask(image, halite_threshold, gypsum_threshold, halite_ng_threshold=None, gypsum_ng_threshold=None)

maskL8clouds(image)

temperature_bands(img)

landsat_LST(image)

PixelAreaSum(image, band_name, geometry, threshold=-1, scale=30, maxPixels=1e12)

dNDWIPixelAreaSum(image, geometry, band_name=’ndwi’, scale=30, maxPixels=1e12)

Usage:

The LandsatCollection object alone acts as a base object for which to further filter or process to indices or spatial reductions

To use the LandsatCollection functionality, use any of the built in class attributes or method functions. For example, using class attributes:

image_collection = LandsatCollection(start_date, end_date, tile_row, tile_path, cloud_percentage_threshold)

ee_image_collection = image_collection.collection #returns ee.ImageCollection from provided argument filters

latest_image = image_collection.image_grab(-1) #returns latest image in collection as ee.Image

cloud_masked_collection = image_collection.masked_clouds_collection #returns cloud-masked LandsatCollection image collection

NDWI_collection = image_collection.ndwi #returns NDWI LandsatCollection image collection

latest_NDWI_image = NDWI_collection.image_grab(-1) #Example showing how class functions work with any LandsatCollection image collection object, returning latest ndwi image

CollectionStitch(img_col2)

Function to mosaic two LandsatCollection objects which share image dates. Mosaics are only formed for dates where both image collections have images. Image properties are copied from the primary collection. Server-side friendly.

Args: self: self is passed into argument, which is a LandsatCollection image collection img_col2: secondary LandsatCollection image collection to be mosaiced with the primary image collection

Returns: image collection (LandsatCollection): LandsatCollection image collection

property LST

Property attribute to calculate and access the LST (Land Surface Temperature - in Celcius) imagery of the LandsatCollection. This property initiates the calculation of LST and caches the result. The calculation is performed only once when the property is first accessed, and the cached result is returned on subsequent accesses.

Args: self: self is passed into argument

Returns: image collection (LandsatCollection): A LandsatCollection image collection object containing LST imagery (temperature in Celcius).

static MaskToWaterLandsat(image)

Function to mask to water pixels by masking land and cloud pixels based on Landsat image QA band.

Args: image (ee.Image): input ee.Image

Returns: image (ee.Image): ee.Imagewith water pixels masked.

static MaskToWaterLandsatByNDWI(image, threshold, ng_threshold=None)

Function to mask water pixels using NDWI based on threshold. Can specify separate thresholds for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9

Args: image (ee.Image): input image threshold (int): value between -1 and 1 where NDWI pixels less than threshold will be masked, applies to landsat 5 when ng_threshold is also set. ng_threshold (int | optional): integer threshold to be applied to landsat 8 or 9 where NDWI pixels less than threshold are masked

Returns: image (ee.Image): ee.Image with water pixels masked.

static MaskWaterLandsat(image)

Function to mask water pixels based on Landsat image QA band.

Args: image (ee.Image): input ee.Image

Returns: image (ee.Image): ee.Image with water pixels masked.

static MaskWaterLandsatByNDWI(image, threshold, ng_threshold=None)

Function to mask water pixels (mask land and cloud pixels) for all bands based on NDWI and a set threshold where all pixels less than NDWI threshold are masked out. Can specify separate thresholds for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9

Args: image (ee.Image): input image threshold (int): value between -1 and 1 where NDWI pixels greater than threshold will be masked, applies to landsat 5 when ng_threshold is also set. ng_threshold (int | optional): integer threshold to be applied to landsat 8 or 9 where NDWI pixels greater than threshold are masked

Returns: image (ee.Image): ee.Image with water pixels masked

property MosaicByDate

Property attribute function to mosaic collection images that share the same date. The property CLOUD_COVER for each image is used to calculate an overall mean, which replaces the CLOUD_COVER property for each mosaiced image. Server-side friendly. NOTE: if images are removed from the collection from cloud filtering, you may have mosaics composed of only one image.

Args: self: self is passed into argument, which is a LandsatCollection image collection

Returns: image collection (LandsatCollection): LandsatCollection image collection with mosaiced imagery and mean CLOUD_COVER as a property

static PixelAreaSum(image, band_name, geometry, threshold=-1, scale=30, maxPixels=1000000000000.0)

Function to calculate the summation of area for pixels of interest (above a specific threshold) in a geometry and store the value as image property (matching name of chosen band).

Args: image (ee.Image): input ee.Image band_name (string): name of band (string) for calculating area geometry (ee.Geometry): ee.Geometry object denoting area to clip to for area calculation threshold (int): integer threshold to specify masking of pixels below threshold (defaults to -1) scale (int): integer scale of image resolution (meters) (defaults to 30) maxPixels (int): integer denoting maximum number of pixels for calculations

Returns: image (ee.Image): ee.Image with area calculation stored as property matching name of band

PixelAreaSumCollection(band_name, geometry, threshold=-1, scale=30, maxPixels=1000000000000.0)

Function to calculate the summation of area for pixels of interest (above a specific threshold) within a geometry and store the value as image property (matching name of chosen band) for an entire image collection. The resulting value has units of square meters.

Args: self: self is the input image collection band_name: name of band (string) for calculating area. geometry: ee.Geometry object denoting area to clip to for area calculation. threshold: integer threshold to specify masking of pixels below threshold (defaults to -1). scale: integer scale of image resolution (meters) (defaults to 30). maxPixels: integer denoting maximum number of pixels for calculations.

Returns: image (ee.Image): Image with area calculation stored as property matching name of band.

property chlorophyll

Property attribute to calculate and access the chlorophyll (NDTI) imagery of the LandsatCollection. This property initiates the calculation of chlorophyll using a default threshold of -1 (or a previously set threshold of self.chlorophyll_threshold) and caches the result. The calculation is performed only once when the property is first accessed, and the cached result is returned on subsequent accesses.

Args: self: self is passed into argument

Returns: image collection (LandsatCollection): A LandsatCollection image collection

chlorophyll_collection(threshold, ng_threshold=None)

Function to calculate the KIVU chlorophyll index and return collection as class object, allows specifying threshold(s) for masking. Thresholds can be specified for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9. This function can be called as a method but is called by default when using the ndwi property attribute.

Args: self: self is passed into argument threshold (int): specify threshold for the turbidity function (values less than threshold are masked) ng_threshold (int): (optional) specify threshold for Landsat 8&9 turbidity function (values less than threshold are masked)

Returns: image collection (LandsatCollection): A LandsatCollection image collection

custom_image_grab(img_col, img_selector)

Function to select (“grab”) image of a specific index from an ee.ImageCollection object.

Args: self: self is passed into argument img_col: ee.ImageCollection with same dates as another LandsatCollection image collection object. img_selector: index of image in list of dates for which user seeks to “select”.

Returns: image (ee.Image): ee.Image of selected image

static dNDWIPixelAreaSum(image, geometry, band_name='ndwi', scale=30, maxPixels=1000000000000.0)

Function to dynamically calulate the summation of area for water pixels of interest and store the value as image property named ‘ndwi’ Uses Otsu thresholding to dynamically choose the best threshold rather than needing to specify threshold. Note: An offset of 0.15 is added to the Otsu threshold.

Args: image (ee.Image): input ee.Image geometry (ee.Geometry): ee.Geometry object denoting area to clip to for area calculation band_name (string): name of ndwi band (string) for calculating area (defaults to ‘ndwi’) scale (int): integer scale of image resolution (meters) (defaults to 30) maxPixels (int): integer denoting maximum number of pixels for calculations

Returns: image (ee.Image): ee.Image with area calculation stored as property matching name of band

property dates

Property attribute to retrieve list of dates as readable and indexable client-side list object.

Args: self: self is passed into argument.

Returns: list: list of date strings.

property dates_list

Property attribute to retrieve list of dates as server-side (GEE) object.

Args: self: self is passed into argument.

Returns: ee.List: Server-side ee.List of dates.

static ee_to_df(ee_object, columns=None, remove_geom=True, sort_columns=False, **kwargs)

Converts an ee.FeatureCollection to pandas dataframe. Adapted from the geemap package (https://geemap.org/common/#geemap.common.ee_to_df)

Args:

ee_object (ee.FeatureCollection): ee.FeatureCollection. columns (list): List of column names. Defaults to None. remove_geom (bool): Whether to remove the geometry column. Defaults to True. sort_columns (bool): Whether to sort the column names. Defaults to False. kwargs: Additional arguments passed to ee.data.computeFeature.

Raises:

TypeError: ee_object must be an ee.FeatureCollection

Returns:

pd.DataFrame: pandas DataFrame

static extract_transect(image, line, reducer='mean', n_segments=100, dist_interval=None, scale=None, crs=None, crsTransform=None, tileScale=1.0, to_pandas=False, **kwargs)

Extracts transect from an image. Adapted from the geemap package (https://geemap.org/common/#geemap.common.extract_transect)

Args:

image (ee.Image): The image to extract transect from. line (ee.Geometry.LineString): The LineString used to extract transect from an image. reducer (str, optional): The ee.Reducer to use, e.g., ‘mean’, ‘median’, ‘min’, ‘max’, ‘stdDev’. Defaults to “mean”. n_segments (int, optional): The number of segments that the LineString will be split into. Defaults to 100. dist_interval (float, optional): The distance interval used for splitting the LineString. If specified, the n_segments parameter will be ignored. Defaults to None. scale (float, optional): A nominal scale in meters of the projection to work in. Defaults to None. crs (ee.Projection, optional): The projection to work in. If unspecified, the projection of the image’s first band is used. If specified in addition to scale, rescaled to the specified scale. Defaults to None. crsTransform (list, optional): The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with ‘scale’, and will replace any transform already set on the projection. Defaults to None. tileScale (float, optional): A scaling factor used to reduce aggregation tile size; using a larger tileScale (e.g. 2 or 4) may enable computations that run out of memory with the default. Defaults to 1. to_pandas (bool, optional): Whether to convert the result to a pandas dataframe. Default to False.

Raises:

TypeError: If the geometry type is not LineString. Exception: If the program fails to compute.

Returns:

ee.FeatureCollection: The FeatureCollection containing the transect with distance and reducer values.

get_boundary_filtered_collection()

Function to filter and mask image collection based on LandsatCollection class arguments. Automatically calculated when using collection method, depending on provided class arguments (when boundary info is provided).

Args: self: self is passed into argument

Returns: ee.ImageCollection: Filtered image collection - used for subsequent analyses or to acquire ee.ImageCollection from LandsatCollection object

get_filtered_collection()

Function to filter image collection based on LandsatCollection class arguments. Automatically calculated when using collection method, depending on provided class arguments (when tile info is provided).

Args: self: self is passed into argument

Returns: ee.ImageCollection: Filtered image collection - used for subsequent analyses or to acquire ee.ImageCollection from LandsatCollection object

property gypsum

Property attribute to calculate and access the gypsum/sulfate index (see Radwin & Bowen, 2021) imagery of the LandsatCollection. This property initiates the calculation of gypsum using a default threshold of -1 (or a previously set threshold of self.gypsum_threshold) and caches the result. The calculation is performed only once when the property is first accessed, and the cached result is returned on subsequent accesses.

Args: self: self is passed into argument

Returns: image collection (LandsatCollection): A LandsatCollection image collection

static gypsum_and_halite_mask(image, halite_threshold, gypsum_threshold, halite_ng_threshold=None, gypsum_ng_threshold=None)

Function to mask both gypsum and halite pixels. Must specify threshold for isolating halite and gypsum pixels. Can specify separate thresholds for Landsat 5 vs 8&9 images where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9.

Args: image (ee.Image): input ee.Image halite_threshold (int): integer threshold for halite where pixels less than threshold are masked, applies to landsat 5 when ng_threshold is also set. gypsum_threshold (int): integer threshold for gypsum where pixels less than threshold are masked, applies to landsat 5 when ng_threshold is also set. halite_ng_threshold (int | optional): integer threshold for halite to be applied to landsat 8 or 9 where pixels less than threshold are masked gypsum_ng_threshold (int | optional): integer threshold for gypsum to be applied to landsat 8 or 9 where pixels less than threshold are masked

Returns: image (ee.Image): masked ee.Image

gypsum_collection(threshold, ng_threshold=None)

Function to calculate the gypsum index (see Radwin & Bowen, 2021) and return collection as class object, allows specifying threshold(s) for masking. Thresholds can be specified for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9. This function can be called as a method but is called by default when using the ndwi property attribute.

Args: self: self is passed into argument threshold (int): specify threshold for gypsum function (values less than threshold are masked) ng_threshold (int): (optional) specify threshold for Landsat 8&9 gypsum function (values less than threshold are masked)

Returns: image collection (LandsatCollection): A LandsatCollection image collection

property halite

Property attribute to calculate and access the halite index (see Radwin & Bowen, 2021) imagery of the LandsatCollection. This property initiates the calculation of halite using a default threshold of -1 (or a previously set threshold of self.halite_threshold) and caches the result. The calculation is performed only once when the property is first accessed, and the cached result is returned on subsequent accesses.

Args: self: self is passed into argument

Returns: image collection (LandsatCollection): A LandsatCollection image collection

halite_collection(threshold, ng_threshold=None)

Function to calculate the halite index (see Radwin & Bowen, 2021) and return collection as class object, allows specifying threshold(s) for masking. Thresholds can be specified for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9. This function can be called as a method but is called by default when using the ndwi property attribute.

Args: self: self is passed into argument threshold (int): specify threshold for halite function (values less than threshold are masked) ng_threshold (int): (optional) specify threshold for Landsat 8&9 halite function (values less than threshold are masked)

Returns: image collection (LandsatCollection): A LandsatCollection image collection

static halite_mask(image, threshold, ng_threshold=None)

Function to mask halite pixels after specifying index to isolate/mask-to halite pixels. Can specify separate thresholds for Landsat 5 vs 8&9 images where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9.

Args: image (ee.Image): input ee.Image threshold (int): value between -1 and 1 where pixels less than threshold will be masked, applies to landsat 5 when ng_threshold is also set. ng_threshold (int | optional): integer threshold to be applied to landsat 8 or 9 where pixels less than threshold are masked

Returns: image (ee.Image): masked ee.Image

static image_dater(image)

Adds date to image properties as ‘Date_Filter’.

Args: image (ee.Image): Input image

Returns: image (ee.Image): Image with date in properties.

image_grab(img_selector)

Function to select (“grab”) an image by index from the collection. Easy way to get latest image or browse imagery one-by-one.

Args: self: self is passed into argument img_selector: index of image in the collection for which user seeks to select/”grab”.

Returns: image (ee.Image): ee.Image of selected image

image_pick(img_date)

Function to select (“grab”) image of a specific date in format of ‘YYYY-MM-DD’ - will not work correctly if collection is composed of multiple images of the same date.

Args: self: self is passed into argument img_date: date (str) of image to select in format of ‘YYYY-MM-DD’

Returns: image (ee.Image): ee.Image of selected image

static landsat5bandrename(img)

Function to rename Landsat 5 bands to match Landsat 8 & 9.

Args: image (ee.Image): input image

Returns: image (ee.Image): image with renamed bands

static landsat_LST(image)

Function to calculate land surface temperature (LST) from landsat TIR bands. Based on Sekertekin, A., & Bonafoni, S. (2020) https://doi.org/10.3390/rs12020294

Args: image (ee.Image): input ee.Image

Returns: image (ee.Image): LST ee.Image

static landsat_gypsum_fn(image, threshold, ng_threshold=None)

Function to calculate multispectral gypsum index for Landsat imagery and mask image based on threshold. Can specify separate thresholds for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9.

Args: image (ee.Image): input ee.Image threshold (int): value between -1 and 1 where pixels less than threshold will be masked, applies to landsat 5 when ng_threshold is also set. ng_threshold (int | optional): integer threshold to be applied to landsat 8 or 9 where pixels less than threshold are masked

Returns: image (ee.Image): gypsum ee.Image

static landsat_halite_fn(image, threshold, ng_threshold=None)

Function to calculate multispectral halite index for Landsat imagery and mask image based on threshold. Can specify separate thresholds for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9.

Args: image (ee.Image): input ee.Image threshold (int): value between -1 and 1 where pixels less than threshold will be masked, applies to landsat 5 when ng_threshold is also set. ng_threshold (int | optional): integer threshold to be applied to landsat 8 or 9 where pixels less than threshold are masked

Returns: image (ee.Image): halite ee.Image

static landsat_kivu_chla_fn(image, threshold, ng_threshold=None)

Function to calculate relative chlorophyll-a concentrations of water pixels using 3BDA/KIVU index (see Boucher et al., 2018 for review) and mask image based on threshold. Can specify separate thresholds for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9.

Args: image (ee.Image): input ee.Image threshold (int): value between -1 and 1 where pixels less than threshold will be masked, applies to landsat 5 when ng_threshold is also set. ng_threshold (int | optional): integer threshold to be applied to landsat 8 or 9 where pixels less than threshold are masked

Returns: image (ee.Image): chlorophyll-a ee.Image

static landsat_ndti_fn(image, threshold, ng_threshold=None)

Function to calculate turbidity of water pixels using Normalized Difference Turbidity Index (NDTI; Lacaux et al., 2007) and mask image based on threshold. Can specify separate thresholds for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9.

Args: image (ee.Image): input ee.Image threshold (int): value between -1 and 1 where pixels less than threshold will be masked, applies to landsat 5 when ng_threshold is also set. ng_threshold (int | optional): integer threshold to be applied to landsat 8 or 9 where pixels less than threshold are masked

Returns: image (ee.Image): turbidity ee.Image

static landsat_ndvi_fn(image, threshold, ng_threshold=None)

Function to calculate ndvi for Landsat imagery and mask image based on threshold. Can specify separate thresholds for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9.

Args: image (ee.Image): input ee.Image threshold (int): value between -1 and 1 where pixels less than threshold will be masked, applies to landsat 5 when ng_threshold is also set. ng_threshold (int | optional): integer threshold to be applied to landsat 8 or 9 where pixels less than threshold are masked

Returns: image (ee.Image): ndvi ee.Image

static landsat_ndwi_fn(image, threshold, ng_threshold=None)

Function to calculate ndwi for Landsat imagery and mask image based on threshold. Can specify separate thresholds for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9.

Args: image (ee.Image): input image threshold (int): value between -1 and 1 where pixels less than threshold will be masked, applies to landsat 5 when ng_threshold is also set. ng_threshold (int | optional): integer threshold to be applied to landsat 8 or 9 where pixels less than threshold are masked

Returns: image (ee.Image): ndwi image

static maskL8clouds(image)

Function to mask clouds baseed on Landsat 8 QA band.

Args: image (ee.Image): input ee.Image

Returns: image (ee.Image): ee.Image

mask_halite(threshold, ng_threshold=None)

Function to mask halite and return collection as class object. Can specify separate thresholds for Landsat 5 vs 8&9 images where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9.

Args: self: self is passed into argument threshold (int): specify threshold for gypsum function (values less than threshold are masked) ng_threshold (int): (optional) specify threshold for Landsat 8&9 gypsum function (values less than threshold are masked).

Returns: image collection (LandsatCollection): LandsatCollection image collection

mask_halite_and_gypsum(halite_threshold, gypsum_threshold, halite_ng_threshold=None, gypsum_ng_threshold=None)

Function to mask halite and gypsum and return collection as class object. Can specify separate thresholds for Landsat 5 vs 8&9 images where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9.

Args: self: self is passed into argument halite_threshold (int): specify threshold for halite function (values less than threshold are masked) halite_ng_threshold (int): (optional) specify threshold for Landsat 8&9 halite function (values less than threshold are masked) gypsum_threshold (int): specify threshold for gypsum function (values less than threshold are masked) gypsum_ng_threshold (int): (optional) specify threshold for Landsat 8&9 gypsum function (values less than threshold are masked)

Returns: image collection (LandsatCollection): LandsatCollection image collection

mask_out_polygon(polygon)

Function to mask LandsatCollection image collection by a polygon (ee.Geometry), where pixels inside the polygon are masked out.

Args: self: self is passed into argument (image collection) polygon (ee.Geometry): ee.Geometry polygon or shape used to mask image collection.

Returns: image collection (LandsatCollection): masked LandsatCollection image collection

mask_to_polygon(polygon)

Function to mask LandsatCollection image collection by a polygon (ee.Geometry), where pixels outside the polygon are masked out.

Args: self: self is passed into argument (image collection) polygon (ee.Geometry): ee.Geometry polygon or shape used to mask image collection.

Returns: image collection (LandsatCollection): masked LandsatCollection image collection

property masked_clouds_collection

Property attribute to mask clouds and return collection as class object.

Args: self: self is passed into argument

Returns: image collection (LandsatCollection): LandsatCollection image collection

property masked_to_water_collection

Property attribute to mask image to water, removing land and cloud pixels, and return collection as class object.

Args: self: self is passed into argument

Returns: image collection (LandsatCollection): LandsatCollection image collection

masked_to_water_collection_NDWI(threshold)

Function to mask all but water pixels based on NDWI and user set threshold.

Args: self: self is passed into argument threshold (int): specify threshold for NDWI function (values less than threshold are masked)

Returns: image collection (LandsatCollection): LandsatCollection image collection

property masked_water_collection

Property attribute to mask water and return collection as class object.

Args: self: self is passed into argument

Returns: image collection (LandsatCollection): LandsatCollection image collection

masked_water_collection_NDWI(threshold)

Function to mask water pixels based on NDWI and user set threshold.

Args: self: self is passed into argument threshold (int): specify threshold for NDWI function (values greater than threshold are masked)

Returns: image collection (LandsatCollection): LandsatCollection image collection

property max

Property attribute function to calculate max image from image collection. Results are calculated once per class object then cached for future use.

Args: self: self is passed into argument

Returns: image (ee.Image): max image from entire collection.

property mean

Property attribute function to calculate mean image from image collection. Results are calculated once per class object then cached for future use.

Args: self: self is passed into argument

Returns: image (ee.Image): mean image from entire collection.

property median

Property attribute function to calculate median image from image collection. Results are calculated once per class object then cached for future use.

Args: self: self is passed into argument

Returns: image (ee.Image): median image from entire collection.

property min

Property attribute function to calculate min image from image collection. Results are calculated once per class object then cached for future use.

Args: self: self is passed into argument

Returns: image (ee.Image): min image from entire collection.

property ndvi

Property attribute to calculate and access the NDVI (Normalized Difference Vegetation Index) imagery of the LandsatCollection. This property initiates the calculation of NDVI using a default threshold of -1 (or a previously set threshold of self.ndvi_threshold) and caches the result. The calculation is performed only once when the property is first accessed, and the cached result is returned on subsequent accesses.

Args: self: self is passed into argument

Returns: image collection (LandsatCollection): A LandsatCollection image collection

ndvi_collection(threshold, ng_threshold=None)

Function to calculate the NDVI (Normalized Difference Vegetation Index) and return collection as class object, allows specifying threshold(s) for masking. Thresholds can be specified for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9. This function can be called as a method but is called by default when using the ndwi property attribute.

Args: self: self is passed into argument threshold (int): specify threshold for NDVI function (values less than threshold are masked)

Returns: image collection (LandsatCollection): A LandsatCollection image collection

property ndwi

Property attribute to calculate and access the NDWI (Normalized Difference Water Index) imagery of the LandsatCollection. This property initiates the calculation of NDWI using a default threshold of -1 (or a previously set threshold of self.ndwi_threshold) and caches the result. The calculation is performed only once when the property is first accessed, and the cached result is returned on subsequent accesses.

Args: self: self is passed into argument

Returns: image collection (LandsatCollection): A LandsatCollection image collection

ndwi_collection(threshold, ng_threshold=None)

Function to calculate ndwi and return collection as class object, allows specifying threshold(s) for masking. Thresholds can be specified for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9. This function can be called as a method but is called by default when using the ndwi property attribute.

Args: self: self is passed into argument threshold (int): specify threshold for NDWI function (values less than threshold are masked)

Returns: image collection (LandsatCollection): A LandsatCollection image collection

surface_temperature_collection()

Function to calculate LST (Land Surface Temperature - in Celcius) and return collection as class object.

Args: self: self is passed into argument

Returns: image collection (LandsatCollection): A LandsatCollection image collection

static temperature_bands(img)

Function to rename bands for temperature calculations.

Args: img: input ee.Image

Returns: image (ee.Image): ee.Image

static transect(image, lines, line_names, reducer='mean', n_segments=None, dist_interval=30, to_pandas=True)
Computes and stores the values along a transect for each line in a list of lines. Builds off of the extract_transect function from the geemap package

where checks are ran to ensure that the reducer column is present in the transect data. If the reducer column is not present, a column of NaNs is created. An ee reducer is used to aggregate the values along the transect, depending on the number of segments or distance interval specified. Defaults to ‘mean’ reducer.

Args:

image (ee.Image): ee.Image object to use for calculating transect values. lines (list): List of ee.Geometry.LineString objects. line_names (list of strings): List of line string names. reducer (str): The ee reducer to use. Defaults to ‘mean’. n_segments (int): The number of segments that the LineString will be split into. Defaults to None. dist_interval (float): The distance interval in meters used for splitting the LineString. If specified, the n_segments parameter will be ignored. Defaults to 30. to_pandas (bool): Whether to convert the result to a pandas dataframe. Defaults to True.

Returns:

pd.DataFrame or ee.FeatureCollection: organized list of values along the transect(s)

transect_iterator(lines, line_names, save_folder_path, reducer='mean', n_segments=None, dist_interval=30, to_pandas=True)
Computes and stores the values along a transect for each line in a list of lines for each image in a LandsatCollection image collection, then saves the data for each image to a csv file. Builds off of the extract_transect function from the geemap package

where checks are ran to ensure that the reducer column is present in the transect data. If the reducer column is not present, a column of NaNs is created. An ee reducer is used to aggregate the values along the transect, depending on the number of segments or distance interval specified. Defaults to ‘mean’ reducer. Naming conventions for the csv files follows as: “image-date_transects.csv”

Args:

self (LandsatCollection image collection): Image collection object to iterate for calculating transect values for each image. lines (list): List of ee.Geometry.LineString objects. line_names (list of strings): List of line string names. save_folder_path (str): The path to the folder where the csv files will be saved. reducer (str): The ee reducer to use. Defaults to ‘mean’. n_segments (int): The number of segments that the LineString will be split into. Defaults to None. dist_interval (float): The distance interval used for splitting the LineString. If specified, the n_segments parameter will be ignored. Defaults to 10. to_pandas (bool): Whether to convert the result to a pandas dataframe. Defaults to True.

Raises:

Exception: If the program fails to compute.

Returns:

csv file: file for each image with an organized list of values along the transect(s)

property turbidity

Property attribute to calculate and access the turbidity (NDTI) imagery of the LandsatCollection. This property initiates the calculation of turbidity using a default threshold of -1 (or a previously set threshold of self.turbidity_threshold) and caches the result. The calculation is performed only once when the property is first accessed, and the cached result is returned on subsequent accesses.

Args: self: self is passed into argument

Returns: image collection (LandsatCollection): A LandsatCollection image collection

turbidity_collection(threshold, ng_threshold=None)

Function to calculate the turbidity (NDTI) index and return collection as class object, allows specifying threshold(s) for masking. Thresholds can be specified for Landsat 5 vs 8&9 images, where the threshold argument applies to Landsat 5 and the ng_threshold argument applies to Landsat 8&9. This function can be called as a method but is called by default when using the ndwi property attribute.

Args: self: self is passed into argument threshold (int): specify threshold for the turbidity function (values less than threshold are masked) ng_threshold (int): (optional) specify threshold for Landsat 8&9 turbidity function (values less than threshold are masked)

Returns: image collection (LandsatCollection): A LandsatCollection image collection