Sentinel2Collection Documentation

class RadGEEToolbox.Sentinel2Collection.Sentinel2Collection(start_date=None, end_date=None, tile=None, cloud_percentage_threshold=None, nodata_threshold=None, boundary=None, relative_orbit_number=None, collection=None)

Class object representing a collection of ESA Sentinel-2 MSIsurface reflectance satellite images at 10 m/px resolution

This class provides methods to filter, process, and analyze Sentinel-2 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 (str or list): MGRS tile(s) of Sentinel image (required unless boundary, relative_orbit_number, or collection is provided) | user is allowed to provide multiple tiles as list (note tile specifications will override boundary or orbits) - see https://hls.gsfc.nasa.gov/products-description/tiling-system/

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

nodata_threshold (int): Integer percentage threshold where only imagery with nodata pixels encompassing a % less than the threshold will be provided (defaults to 100)

boundary (ee.Geometry): Boundary for filtering images to images that intersect with the boundary shape (optional) - can be used in conjunction with relative_orbit_number

relative_orbit_number (int or list): Relative orbit number(s) to filter collection (optional) - can be used in conjunction with boundary | provide multiple values as list

collection (ee.ImageCollection): Optional argument to convert an ee.ImageCollection object to a Sentinel2Collection object - will override other arguments!

Attributes:

collection (returns: ee.ImageCollection): Returns an ee.ImageCollection object from any Sentinel2Collection 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

_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: Sentinel2Collection image collection): Returns collection with clouds masked (transparent) for each image

masked_to_water_collection (returns: Sentinel2Collection image collection): Returns collection masked to just water pixels

masked_water_collection (returns: Sentinel2Collection image collection): Returns collection with water pixels masked

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)

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

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

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

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

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

chlorophyll (returns: ee.ImageCollection): Returns Sentinel2Collection image collection of singleband 2BDA (relative chlorophyll-a) rasters

MosaicByDate (returns: Sentinel2Collection 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.

Methods:

ndwi_collection(self, threshold)

ndvi_collection(self, threshold)

halite_collection(self, threshold)

gypsum_collection(self, threshold)

turbidity_collection(self, threshold)

chlorophyll_collection(self, threshold)

get_filtered_collection(self)

get_boundary_filtered_collection(self)

get_orbit_filtered_collection(self)

get_orbit_and_boundary_filtered_collection(self)

mask_to_polygon(self, polygon)

mask_out_polygon(self, polygon)

masked_water_collection_NDWI(self, threshold)

masked_to_water_collection_NDWI(self, threshold)

mask_halite(self, threshold)

mask_halite_and_gypsum(self, halite_threshold, gypsum_threshold)

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)

sentinel_ndwi_fn(image, threshold)

sentinel_ndvi_fn(image, threshold)

sentinel_halite_fn(image, threshold)

sentinel_gypsum_fn(image, threshold)

sentinel_turbidity_fn(image, threshold)

sentinel_chlorophyll_fn(image, threshold)

MaskWaterS2(image)

MaskToWaterS2(image)

MaskWaterS2ByNDWI(image, threshold)

MaskToWaterS2ByNDWI(image, threshold)

halite_mask(image, threshold)

gypsum_and_halite_mask(image, halite_threshold, gypsum_threshold)

MaskCloudsS2(image)

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

Usage:

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

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

image_collection = Sentinel2Collection(start_date, end_date, tile, 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 Sentinel2Collection image collection

NDWI_collection = image_collection.ndwi #returns NDWI Sentinel2Collection image collection

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

CollectionStitch(img_col2)

Function to mosaic two Sentinel2Collection 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 Sentinel2Collection image collection. img_col2: secondary Sentinel2Collection image collection to be mosaiced with the primary image collection.

Returns: image collection (Sentinel2Collection): Sentinel2Collection image collection

static MaskCloudsS2(image)

Function to map clouds using SCL band data.

Args: image (ee.Image): input image

Returns: image (ee.Image): output ee.Image with clouds masked

static MaskToWaterS2(image)

Function to mask to water pixels (mask land and cloud pixels) using SCL band data.

Args: image (ee.Image): input image

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

static MaskToWaterS2ByNDWI(image, threshold)

Function to mask all bands to water pixels (mask land and cloud pixels) based on NDWI.

Args: image (ee.Image): input image threshold (int): value between -1 and 1 where pixels less than threshold will be masked.

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

static MaskWaterS2(image)

Function to mask water pixels using SCL band data.

Args: image (ee.Image): input image

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

static MaskWaterS2ByNDWI(image, threshold)

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.

Args: image (ee.Image): input image threshold (int): value between -1 and 1 where pixels less than threshold will be masked.

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

property MosaicByDate

Property attribute function to mosaic collection images that share the same date. The properties CLOUD_PIXEL_PERCENTAGE and NODATA_PIXEL_PERCENTAGE for each image are used to calculate an overall mean, which replaces the CLOUD_PIXEL_PERCENTAGE and NODATA_PIXEL_PERCENTAGE 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 Sentinel2Collection image collection.

Returns: image collection (Sentinel2Collection): Sentinel2Collection image collection

static PixelAreaSum(image, band_name, geometry, threshold=-1, scale=10, 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). The resulting value has units of square meters.

Args: image (ee.Image): input ee.Image 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 10). maxPixels: integer denoting maximum number of pixels for calculations.

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

PixelAreaSumCollection(band_name, geometry, threshold=-1, scale=10, 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 10). 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 Sentinel2Collection. 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 (Sentinel2Collection): A Sentinel2Collection image collection.

chlorophyll_collection(threshold)

Function to calculate 2BDA chlorophyll index and return collection as class object. Masks collection based on threshold which defaults to 0.5.

Args: self: self is passed into argument. threshold: specify threshold for 2BDA function (values less than threshold are masked).

Returns: image collection (Sentinel2Collection): Sentinel2Collection 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 Sentinel2Collection 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.

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 in meters 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 image collection using a geometry/boundary rather than list of tiles (based on Sentinel2Collection class arguments).

Args: self: self is passed into argument.

Returns: image collection (ee.ImageCollection): Image collection objects

get_filtered_collection()

Function to filter image collection using a list of MGRS tiles (based on Sentinel2Collection class arguments).

Args: self: self is passed into argument.

Returns: image collection (ee.ImageCollection): Image collection objects

get_orbit_and_boundary_filtered_collection()

Function to filter image collection a list of relative orbit numbers and geometry/boundary rather than list of tiles (based on Sentinel2Collection class arguments).

Args: self: self is passed into argument.

Returns: image collection (ee.ImageCollection): Image collection objects

get_orbit_filtered_collection()

Function to filter image collection a list of relative orbit numbers rather than list of tiles (based on Sentinel2Collection class arguments).

Args: self: self is passed into argument.

Returns: image collection (ee.ImageCollection): Image collection objects

property gypsum

Property attribute to calculate and access the gypsum/sulfate index (see Radwin & Bowen, 2021) imagery of the Sentinel2Collection. 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 (Sentinel2Collection): A Sentinel2Collection image collection.

static gypsum_and_halite_mask(image, halite_threshold, gypsum_threshold)

Function to mask both gypsum and halite pixels. Must specify threshold for isolating halite and gypsum pixels.

Args: image (ee.Image): input image halite_threshold: integer threshold for halite where pixels less than threshold are masked. gypsum_threshold: integer threshold for gypsum where pixels less than threshold are masked.

Returns: image (ee.Image): ee.Image where gypsum and halite pixels are masked (image without halite or gypsum pixels).

gypsum_collection(threshold)

Function to calculate multispectral gypsum index and return collection as class object. Masks collection based on threshold which defaults to -1.

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

Returns: image collection (Sentinel2Collection): Sentinel2Collection image collection.

property halite

Property attribute to calculate and access the halite index (see Radwin & Bowen, 2021) imagery of the Sentinel2Collection. 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 (Sentinel2Collection): A Sentinel2Collection image collection.

halite_collection(threshold)

Function to calculate multispectral halite index and return collection as class object. Masks collection based on threshold which defaults to -1.

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

Returns: image collection (Sentinel2Collection): Sentinel2Collection image collection.

static halite_mask(image, threshold)

Function to mask halite pixels after specifying index to isolate/mask-to halite pixels.

Args: image (ee.Image): input image threshold (int): value between -1 and 1 where pixels less than threshold will be masked..

Returns: image (ee.Image): ee.Image where halite pixels are masked (image without halite pixels).

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.

mask_halite(threshold)

Function to mask halite and return collection as class object.

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

Returns: image collection (Sentinel2Collection): Sentinel2Collection image collection

mask_halite_and_gypsum(halite_threshold, gypsum_threshold)

Function to mask halite and gypsum and return collection as class object.

Args: self: self is passed into argument halite_threshold: specify threshold for halite function (values less than threshold are masked). gypsum_threshold: specify threshold for gypsum function (values less than threshold are masked).

Returns: image collection (Sentinel2Collection): Sentinel2Collection image collection

mask_out_polygon(polygon)

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

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

Returns: image collection (Sentinel2Collection): masked Sentinel2Collection image collection.

mask_to_polygon(polygon)

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

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

Returns: image collection (Sentinel2Collection): masked Sentinel2Collection 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 (Sentinel2Collection): masked Sentinel2Collection image collection.

property masked_to_water_collection

Property attribute to mask to water (mask land and cloud pixels) and return collection as class object.

Args: self: self is passed into argument.

Returns: image collection (Sentinel2Collection): Sentinel2Collection image collection.

masked_to_water_collection_NDWI(threshold)

Function to mask to water pixels by using NDWI and return collection as class object

Args: self: self is passed into argument

Returns: image collection (Sentinel2Collection): Sentinel2Collection 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 (Sentinel2Collection): Sentinel2Collection image collection.

masked_water_collection_NDWI(threshold)

Function to mask water by using NDWI and return collection as class object.

Args: self: self is passed into argument.

Returns: image collection (Sentinel2Collection): Sentinel2Collection 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 Sentinel2Collection. 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 (Sentinel2Collection): A Sentinel2Collection image collection.

ndvi_collection(threshold)

Function to calculate ndvi and return collection as class object. Masks collection based on threshold which defaults to -1.

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

Returns: image collection (Sentinel2Collection): Sentinel2Collection image collection.

property ndwi

Property attribute to calculate and access the NDWI (Normalized Difference Water Index) imagery of the Sentinel2Collection. 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 (Sentinel2Collection): A Sentinel2Collection image collection.

ndwi_collection(threshold)

Function to calculate ndwi and return collection as class object. Masks collection based on threshold which defaults to -1.

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

Returns: image collection (Sentinel2Collection): Sentinel2Collection image collection.

static sentinel_chlorophyll_fn(image, threshold)

Function to calculate relative chlorophyll-a concentrations of water pixels using 2BDA index (see Buma and Lee, 2020 for review) and mask image based on threshold. NOTE: the image is downsampled to 20 meters as the red edge 1 band is utilized.

Args: image (ee.Image): input image threshold (int): value between -1 and 1 where pixels less than threshold will be masked.

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

static sentinel_gypsum_fn(image, threshold)

Function to calculate multispectral gypsum index for Sentinel2 imagery and mask image based on threshold.

Args: image (ee.Image): input image threshold (int): value between -1 and 1 where pixels less than threshold will be masked.

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

static sentinel_halite_fn(image, threshold)

Function to calculate multispectral halite index for Sentinel2 imagery and mask image based on threshold.

Args: image (ee.Image): input image threshold (int): value between -1 and 1 where pixels less than threshold will be masked.

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

static sentinel_ndvi_fn(image, threshold)

Function to calculate ndvi for for Sentinel2 imagery and mask image based on threshold.

Args: image (ee.Image): input image threshold (int): value between -1 and 1 where pixels less than threshold will be masked.

Returns: image (ee.Image): ndvi image

static sentinel_ndwi_fn(image, threshold)

Function to calculate ndwi for Sentinel2 imagery and mask image based on threshold.

Args: image (ee.Image): input image threshold (int): value between -1 and 1 where pixels less than threshold will be masked.

Returns: image (ee.Image): ndwi image

static sentinel_turbidity_fn(image, threshold)

Function to calculate Normalized Difference Turbidity Index (NDTI; Lacaux et al., 2007) for for Sentinel2 imagery and mask image based on threshold.

Args: image (ee.Image): input image threshold (int): value between -1 and 1 where pixels less than threshold will be masked.

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

static transect(image, lines, line_names, reducer='mean', n_segments=None, dist_interval=10, 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 10. 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=10, to_pandas=True)
Computes and stores the values along a transect for each line in a list of lines for each image in a Sentinel2Collection 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 (Sentinel2Collection 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 in meters 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 Sentinel2Collection. 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 (Sentinel2Collection): A Sentinel2Collection image collection.

turbidity_collection(threshold)

Function to calculate NDTI turbidity index and return collection as class object. Masks collection based on threshold which defaults to -1.

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

Returns: image collection (Sentinel2Collection): Sentinel2Collection image collection.