Sentinel2Collection
- 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, scale_bands=False)
Bases:
objectRepresents a user-defined collection of ESA Sentinel-2 MSI surface reflectance satellite images at 10 m/px from Google Earth Engine (GEE).
This class enables simplified definition, filtering, masking, and processing of multispectral Sentinel-2 imagery. It supports multiple spatial and temporal filters, caching for efficient computation, and direct computation of key spectral indices like NDWI, NDVI, halite index, and more. It also includes utilities for cloud masking, mosaicking, zonal statistics, and transect analysis.
Initialization can be done by providing filtering parameters or directly passing in a pre-filtered GEE collection.
Inspect the documentation or source code for details on the methods and properties available.
- Parameters:
start_date (str) – Start date in ‘YYYY-MM-DD’ format. Required unless collection is provided.
end_date (str) – End date in ‘YYYY-MM-DD’ format. 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. The 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, optional) – Max allowed cloud cover percentage. Defaults to 100.
nodata_threshold (int, optional) – Integer percentage threshold where only imagery with nodata pixels encompassing a % less than the threshold will be provided (defaults to 100)
boundary (ee.Geometry, optional) – A geometry for filtering to images that intersect with the boundary shape. Overrides tile if provided.
relative_orbit_number (int or list, optional) – Relative orbit number(s) to filter collection. Provide multiple values as list
collection (ee.ImageCollection, optional) – A pre-filtered Sentinel-2 ee.ImageCollection object to be converted to a Sentinel2Collection object. Overrides all other filters.
scale_bands (bool, optional) – If True, all SR bands will be scaled from DN values to reflectance values. Defaults to False.
- collection
The filtered or user-supplied image collection converted to an ee.ImageCollection object.
- Type:
ee.ImageCollection
- Raises:
ValueError – Raised if required filter parameters are missing, or if both collection and other filters are provided.
Note
See full usage examples in the documentation or notebooks: https://github.com/radwinskis/RadGEEToolbox/tree/main/Example%20Notebooks
Examples
>>> from RadGEEToolbox import Sentinel2Collection >>> import ee >>> ee.Initialize() >>> image_collection = Sentinel2Collection( ... start_date='2023-06-01', ... end_date='2023-06-30', ... tile=['12TUL', '12TUM', '12TUN'], ... cloud_percentage_threshold=20, ... nodata_threshold=10, ... ) >>> mosaic_collection = image_collection.mosaicByDate #mosaic images/tiles with same date >>> cloud_masked = mosaic_collection.masked_clouds_collection #mask out clouds >>> latest_image = cloud_masked.image_grab(-1) #grab latest image for viewing >>> ndwi_collection = cloud_masked.ndwi #calculate ndwi for all images
- property add_month_property
Adds a numeric ‘month’ property to each image in the collection.
- Returns:
A Sentinel2Collection image collection with the ‘month’ property added to each image.
- Return type:
- static add_month_property_fn(image)
Adds a numeric ‘month’ property to the image based on its date.
- Parameters:
image (ee.Image) – Input image.
- Returns:
Image with the ‘month’ property added.
- Return type:
ee.Image
- property albedo
//doi.org/10.1016/j.rse.2018.08.025). Use albedo_collection(snow_free=False) for images with snow present. This property initiates the calculation of albedo 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.
- Returns:
A Sentinel2Collection image collection
- Return type:
- Type:
Property attribute to calculate albedo imagery for snow-free conditions, based on Li et al., 2018 (https
- albedo_collection(snow_free=True)
Calculates albedo for snow or snow-free conditions and returns collection as class object, allows specifying threshold(s) for masking. This function can be called as a method but is called by default when using the ndwi property attribute. Albedo calculation based on Li et al., 2018 (https://doi.org/10.1016/j.rse.2018.08.025).
- Parameters:
snow_free (bool) – If True, applies a snow mask to the albedo calculation. Defaults to True.
- Returns:
A Sentinel2Collection image collection
- Return type:
- anomaly(geometry, band_name=None, anomaly_band_name=None, replace=True, scale=10)
Calculates the anomaly of each image in a collection compared to the mean of each image.
This function computes the anomaly for each band in the input image by subtracting the mean value of that band from a provided ImageCollection. The anomaly is a measure of how much the pixel values deviate from the average conditions represented by the collection.
- Parameters:
geometry (ee.Geometry) – The geometry for image reduction to define the mean value to be used for anomaly calculation.
band_name (str, optional) – A string representing the band name to be used for the output anomaly image. If not provided, the band name of the first band of the input image will be used.
anomaly_band_name (str, optional) – A string representing the band name to be used for the output anomaly image. If not provided, the band name of the first band of the input image will be used.
replace (bool, optional) – A boolean indicating whether to replace the original band with the anomaly band. If True, the output image will only contain the anomaly band. If False, the output image will retain all original bands and add the anomaly band. Default is True.
scale (int, optional) – The scale (in meters) to use for the image reduction. Default is 10 meters.
- Returns:
- A Sentinel2Collection where each image represents the anomaly (deviation from
the mean) for the chosen band. The output images retain the same band name.
- Return type:
- static anomaly_fn(image, geometry, band_name=None, anomaly_band_name=None, replace=True, scale=10)
Calculates the anomaly of a singleband image compared to the mean of the singleband image.
This function computes the anomaly for each band in the input image by subtracting the mean value of that band from a provided image. The anomaly is a measure of how much the pixel values deviate from the average conditions represented by the mean of the image.
- Parameters:
image (ee.Image) – An ee.Image for which the anomaly is to be calculated. It is assumed that this image is a singleband image.
geometry (ee.Geometry) – The geometry for image reduction to define the mean value to be used for anomaly calculation.
band_name (str, optional) – A string representing the band name to be used for the output anomaly image. If not provided, the band name of the first band of the input image will be used.
anomaly_band_name (str, optional) – A string representing the band name to be used for the output anomaly image. If not provided, the band name of the first band of the input image will be used.
replace (bool, optional) – A boolean indicating whether to replace the original band with the anomaly band in the output image. If True, the output image will contain only the anomaly band. If False, the output image will contain both the original band and the anomaly band. Default is True.
scale (int, optional) – The scale in meters to use for the reduction operation. Default is 10 meters.
- Returns:
- An ee.Image where each band represents the anomaly (deviation from
the mean) for that band. The output image retains the same band name.
- Return type:
ee.Image
- binary_mask(threshold=None, band_name=None, classify_above_threshold=True, mask_zeros=False)
Function to create a binary mask (value of 1 for pixels above set threshold and value of 0 for all other pixels) of the Sentinel2Collection image collection based on a specified band. If a singleband image is provided, the band name is automatically determined. If multiple bands are available, the user must specify the band name to use for masking.
- Parameters:
threshold (float, optional) – The threshold value for creating the binary mask. Defaults to None.
band_name (str, optional) – The name of the band to use for masking. Defaults to None.
classifiy_above_threshold (bool, optional) – If True, pixels above the threshold are classified as 1. If False, pixels below the threshold are classified as 1. Defaults to True.
mask_zeros (bool, optional) – If True, pixels with a value of 0 after the binary mask are masked out in the output binary mask. Useful for classifications. Defaults to False.
- Returns:
Sentinel2Collection singleband image collection with binary masks applied.
- Return type:
- 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.
- Returns:
A Sentinel2Collection image collection.
- Return type:
- chlorophyll_collection(threshold)
Calculates 2BDA chlorophyll index and return collection as class object. Masks collection based on threshold which defaults to 0.5.
- Parameters:
threshold – specify threshold for 2BDA function (values less than threshold are masked).
- Returns:
Sentinel2Collection image collection.
- Return type:
- 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.
- Parameters:
img_col2 – secondary Sentinel2Collection image collection to be mosaiced with the primary image collection.
- Returns:
Sentinel2Collection image collection
- Return type:
- combine(other)
Combines the current Sentinel2Collection with another Sentinel2Collection, using the combine method.
- Parameters:
other (Sentinel2Collection) – Another Sentinel2Collection to combine with current collection.
- Returns:
A new Sentinel2Collection containing images from both collections.
- Return type:
- custom_image_grab(img_col, img_selector)
Function to select (“grab”) image of a specific index from an ee.ImageCollection object.
- Parameters:
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:
ee.Image of selected image.
- Return type:
ee.Image
- property dates
Property attribute to retrieve list of dates as readable and indexable client-side list object.
- Returns:
list of date strings.
- Return type:
list
- property dates_list
Property attribute to retrieve list of dates as server-side (GEE) object.
- Returns:
Server-side ee.List of dates.
- Return type:
ee.List
- 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)
- Parameters:
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:
pandas DataFrame
- Return type:
pd.DataFrame
- property evi
Property attribute to calculate and access the EVI (Enhanced Vegetation Index) imagery of the Sentinel2Collection. This property initiates the calculation of EVI 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.
- Returns:
A Sentinel2Collection image collection
- Return type:
- evi_collection(threshold)
Function to calculate the EVI (Enhanced Vegetation Index) and return collection as class object, allows specifying threshold(s) for masking. This function can be called as a method but is called by default when using the evi property attribute.
- Parameters:
threshold (float) – specify threshold for EVI function (values less than threshold are masked)
- Returns:
A Sentinel2Collection image collection
- Return type:
- exportProperties(property_names, file_path=None)
Fetches and returns specified properties from each image in the collection as a list, and returns a pandas DataFrame and optionally saves the results to a csv file.
- Parameters:
property_names (list or str) – A property name or list of property names to retrieve. The ‘Date_Filter’ property is always included to provide temporal context.
file_path (str, optional) – If provided, the function will save the resulting DataFrame to a CSV file at this path. Defaults to None.
- Returns:
A pandas DataFrame containing the requested properties for each image, sorted chronologically by ‘Date_Filter’.
- Return type:
pd.DataFrame
- export_to_asset_collection(asset_collection_path, region, scale, dates=None, filename_prefix='', crs=None, max_pixels=10000000000000, description_prefix='export', overwrite=False)
Exports an image collection to a Google Earth Engine asset collection. The asset collection will be created if it does not already exist, and each image exported will be named according to the provided filename prefix and date.
- Parameters:
asset_collection_path (str) – The path to the asset collection.
region (ee.Geometry) – The region to export.
scale (int) – The scale of the export.
dates (list, optional) – The dates to export. Defaults to None.
filename_prefix (str, optional) – The filename prefix. Defaults to “”, i.e. blank.
crs (str, optional) – The coordinate reference system. Defaults to None, which will use the image’s CRS.
max_pixels (int, optional) – The maximum number of pixels. Defaults to int(1e13).
description_prefix (str, optional) – The description prefix. Defaults to “export”.
overwrite (bool, optional) – Whether to overwrite existing assets. Defaults to False.
- Returns:
(queues export tasks)
- Return type:
None
- 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).
- Parameters:
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:
The FeatureCollection containing the transect with distance and reducer values.
- Return type:
ee.FeatureCollection
- static extract_zonal_stats_from_buffer(image, coordinates, buffer_size=1, reducer_type='mean', scale=10, tileScale=1, coordinate_names=None)
Function to extract spatial statistics from an image for a list or single set of (long, lat) coordinates, providing individual statistics for each location. A radial buffer is applied around each coordinate to extract the statistics, which defaults to 1 meter. The function returns a pandas DataFrame with the statistics for each coordinate.
NOTE: Be sure the coordinates are provided as longitude, latitude (x, y) tuples!
- Parameters:
image (ee.Image) – The image from which to extract statistics. Should be single-band.
coordinates (list or tuple) – A single (lon, lat) tuple or a list of (lon, lat) tuples.
buffer_size (int, optional) – The radial buffer size in meters. Defaults to 1.
reducer_type (str, optional) – The ee.Reducer to use (‘mean’, ‘median’, ‘min’, etc.). Defaults to ‘mean’.
scale (int, optional) – The scale in meters for the reduction. Defaults to 10.
tileScale (int, optional) – The tile scale factor. Defaults to 1.
coordinate_names (list, optional) – A list of names for the coordinates.
- Returns:
- A pandas DataFrame with the image’s ‘Date_Filter’ as the index and a
column for each coordinate location.
- Return type:
pd.DataFrame
- get_boundary_filtered_collection()
Function to filter image collection using a geometry/boundary rather than list of tiles (based on Sentinel2Collection class arguments).
- Returns:
Image collection objects
- Return type:
ee.ImageCollection
- get_filtered_collection()
Function to filter image collection using a list of MGRS tiles (based on Sentinel2Collection class arguments).
- Returns:
Image collection objects
- Return type:
ee.ImageCollection
- 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).
- Returns:
Image collection objects
- Return type:
ee.ImageCollection
- 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).
- Returns:
Image collection objects
- Return type:
ee.ImageCollection
- 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.
- Returns:
A Sentinel2Collection image collection.
- Return type:
- 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.
- Parameters:
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:
ee.Image where gypsum and halite pixels are masked (image without halite or gypsum pixels).
- Return type:
ee.Image
- gypsum_collection(threshold)
Calculates multispectral gypsum index and return collection as class object. Masks collection based on threshold which defaults to -1.
- Parameters:
threshold – specify threshold for gypsum function (values less than threshold are masked).
- Returns:
Sentinel2Collection image collection.
- Return type:
- 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.
- Returns:
A Sentinel2Collection image collection.
- Return type:
- halite_collection(threshold)
Calculates multispectral halite index and return collection as class object. Masks collection based on threshold which defaults to -1.
- Parameters:
threshold – specify threshold for halite function (values less than threshold are masked).
- Returns:
Sentinel2Collection image collection.
- Return type:
- static halite_mask(image, threshold)
Function to mask halite pixels after specifying index to isolate/mask-to halite pixels.
- Parameters:
image (ee.Image) – input image
threshold (float) – value between -1 and 1 where pixels less than threshold will be masked..
- Returns:
ee.Image where halite pixels are masked (image without halite pixels).
- Return type:
ee.Image
- static image_dater(image)
Adds date to image properties as ‘Date_Filter’.
- Parameters:
image (ee.Image) – Input image
- Returns:
Image with date in properties.
- Return type:
ee.Image
- 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.
- Parameters:
img_selector – index of image in the collection for which user seeks to select/”grab”.
- Returns:
ee.Image of selected image.
- Return type:
ee.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.
- Parameters:
img_date – date (str) of image to select in format of ‘YYYY-MM-DD’.
- Returns:
ee.Image of selected image.
- Return type:
ee.Image
- iterate_zonal_stats(geometries, band=None, reducer_type='mean', scale=30, geometry_names=None, buffer_size=1, tileScale=1, dates=None, file_path=None, unweighted=False)
Iterates over a collection of images and extracts spatial statistics (defaults to mean) for a given list of geometries or coordinates. Individual statistics are calculated for each geometry or coordinate provided. When coordinates are provided, a radial buffer is applied around each coordinate to extract the statistics, where the size of the buffer is determined by the buffer_size argument (defaults to 1 meter). The function returns a pandas DataFrame with the statistics for each coordinate and date, or optionally exports the data to a table in .csv format.
NOTE: The expected input is a singleband image. If a multiband image is provided, the first band will be used for zonal statistic extraction, unless band is specified.
- Parameters:
geometries (ee.Geometry, ee.Feature, ee.FeatureCollection, list, or tuple) – Input geometries for which to extract statistics. Can be a single ee.Geometry, an ee.Feature, an ee.FeatureCollection, a list of (lon, lat) tuples, or a list of ee.Geometry objects. Be careful to NOT provide coordinates as (lat, lon)!
band (str, optional) – The name of the band to use for statistics. If None, the first band is used. Defaults to None.
reducer_type (str, optional) – The ee.Reducer to use, e.g., ‘mean’, ‘median’, ‘max’, ‘sum’. Defaults to ‘mean’. Any ee.Reducer method can be used.
scale (int, optional) – Pixel scale in meters for the reduction. Defaults to 30.
geometry_names (list, optional) – A list of string names for the geometries. If provided, must match the number of geometries. Defaults to None.
buffer_size (int, optional) – Radial buffer in meters around coordinates. Defaults to 1.
tileScale (int, optional) – A scaling factor to reduce aggregation tile size. Defaults to 1.
dates (list, optional) – A list of date strings (‘YYYY-MM-DD’) for filtering the collection, such that only images from these dates are included for zonal statistic retrieval. Defaults to None, which uses all dates in the collection.
file_path (str, optional) – File path to save the output CSV.
unweighted (bool, optional) – Whether to use an unweighted reducer. Defaults to False.
- Returns:
- A pandas DataFrame with dates as the index and coordinate names
as columns. Returns None if using ‘iterative’ mode with file_path.
- Return type:
pd.DataFrame or None
- Raises:
ValueError – If input parameters are invalid.
TypeError – If geometries input type is unsupported.
- mann_kendall_trend(target_band=None, join_method='system:time_start', geometry=None)
Calculates the Mann-Kendall S-value, Variance, Z-Score, and Confidence Level for each pixel in the image collection, in addition to calculating the Sen’s slope for each pixel in the image collection. The output is an image with the following bands: ‘s_statistic’, ‘variance’, ‘z_score’, ‘confidence’, and ‘slope’.
This function can be used to identify trends in the image collection over time, such as increasing or decreasing values in the target band, and can be used to assess the significance of these trends. Note that this function is computationally intensive and may take a long time to run for large image collections or high-resolution images.
The ‘s_statistic’ band represents the Mann-Kendall S-value, which is a measure of the strength and direction of the trend. The ‘variance’ band represents the variance of the S-value, which is a measure of the variability of the S-value. The ‘z_score’ band represents the Z-Score, which is a measure of the significance of the trend. The ‘confidence’ band represents the confidence level of the trend based on the z_score, which is a probabilistic measure of the confidence in the trend (percentage). The ‘slope’ band represents the Sen’s slope, which is a measure of the rate of change in the target band over time. This value can be small as multispectral indices commonly range from -1 to 1, so a slope may have values of <0.2 for most cases.
Be sure to select the correct band for the target_band parameter, as this will be used to calculate the trend statistics. You may optionally provide an ee.Geometry object for the geometry parameter to limit the area over which the trend statistics are calculated. The geometry parameter is optional and defaults to None, which means that the trend statistics will be calculated over the entire footprint of the image collection.
- Parameters:
image_collection (Sentinel2Collection or ee.ImageCollection) – The input image collection for which the Mann-Kendall and Sen’s slope trend statistics will be calculated.
target_band (str) – The band name to be used for the output anomaly image. e.g. ‘ndvi’
join_method (str, optional) – The method used to join images in the collection. Options are ‘system:time_start’ or ‘Date_Filter’. Default is ‘system:time_start’.
geometry (ee.Geometry, optional) – An ee.Geometry object to limit the area over which the trend statistics are calculated and mask the output image. Default is None.
- Returns:
An image with the following bands: ‘s_statistic’, ‘variance’, ‘z_score’, ‘confidence’, and ‘slope’.
- Return type:
ee.Image
- static maskClouds(image)
Function to mask clouds using SCL band data.
- Parameters:
image (ee.Image) – input image
- Returns:
output ee.Image with clouds masked
- Return type:
ee.Image
- static maskShadows(image)
Function to mask cloud shadows using SCL band data.
- Parameters:
image (ee.Image) – input image
- Returns:
output ee.Image with cloud shadows masked
- Return type:
ee.Image
- static maskToWater(image)
Function to mask to water pixels (mask land and cloud pixels) using SCL band data.
- Parameters:
image (ee.Image) – input image
- Returns:
output ee.Image with all but water pixels masked
- Return type:
ee.Image
- static maskToWaterByNDWI(image, threshold)
Function to mask all bands to water pixels (mask land and cloud pixels) based on NDWI.
- Parameters:
image (ee.Image) – input image
threshold (float) – value between -1 and 1 where pixels less than threshold will be masked.
- Returns:
ee.Image image
- Return type:
ee.Image
- static maskWater(image)
Function to mask water pixels using SCL band data.
- Parameters:
image (ee.Image) – input image
- Returns:
output ee.Image with water pixels masked
- Return type:
ee.Image
- static maskWaterByNDWI(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.
- Parameters:
image (ee.Image) – input image
threshold (float) – value between -1 and 1 where pixels less than threshold will be masked.
- Returns:
ee.Image
- Return type:
ee.Image
- mask_halite(threshold)
Function to mask halite and return collection as class object.
- Parameters:
threshold – specify threshold for gypsum function (values less than threshold are masked).
- Returns:
Sentinel2Collection image collection
- Return type:
- mask_halite_and_gypsum(halite_threshold, gypsum_threshold)
Function to mask halite and gypsum and return collection as class object.
- Parameters:
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:
Sentinel2Collection image collection
- Return type:
- mask_out_polygon(polygon)
Function to mask Sentinel2Collection image collection by a polygon (ee.Geometry), where pixels inside the polygon are masked out.
- Parameters:
polygon – ee.Geometry polygon or shape used to mask image collection.
- Returns:
masked Sentinel2Collection image collection.
- Return type:
- mask_to_polygon(polygon)
Function to mask Sentinel2Collection image collection by a polygon (ee.Geometry), where pixels outside the polygon are masked out.
- Parameters:
polygon – ee.Geometry polygon or shape used to mask image collection.
- Returns:
masked Sentinel2Collection image collection.
- Return type:
- mask_via_band(band_to_mask, band_for_mask, threshold=-1, mask_above=True, add_band_to_original_image=False)
Masks select pixels of a selected band from an image based on another specified band and threshold (optional). Example use case is masking vegetation from image when targeting land pixels. Can specify whether to mask pixels above or below the threshold.
- Parameters:
band_to_mask (str) – name of the band which will be masked (target image)
band_for_mask (str) – name of the band to use for the mask (band you want to remove/mask from target image)
threshold (float) – value between -1 and 1 where pixels less than threshold will be masked; defaults to -1 assuming input band is already classified (masked to pixels of interest).
mask_above (bool) – if True, masks pixels above the threshold; if False, masks pixels below the threshold
- Returns:
A new Sentinel2Collection with the specified band masked to pixels excluding from band_for_mask.
- Return type:
- static mask_via_band_fn(image, band_to_mask, band_for_mask, threshold, mask_above=False, add_band_to_original_image=False)
Masks pixels of interest from a specified band of a target image, based on a specified reference band and threshold. Designed for single image input which contains both the target and reference band. Example use case is masking vegetation from image when targeting land pixels. Can specify whether to mask pixels above or below the threshold.
- Parameters:
image (ee.Image) – input ee.Image
band_to_mask (str) – name of the band which will be masked (target image)
band_for_mask (str) – name of the band to use for the mask (band you want to remove/mask from target image)
threshold (float) – value where pixels less or more than threshold (depending on mask_above argument) will be masked
mask_above (bool) – if True, masks pixels above the threshold; if False, masks pixels below the threshold
- Returns:
masked ee.Image
- Return type:
ee.Image
- mask_via_singleband_image(image_collection_for_mask, band_name_to_mask, band_name_for_mask, threshold=-1, mask_above=False, add_band_to_original_image=False)
Masks select pixels of a selected band from an image collection based on another specified singleband image collection and threshold (optional). Example use case is masking vegetation from image when targeting land pixels. Can specify whether to mask pixels above or below the threshold. This function pairs images from the two collections based on an exact match of the ‘Date_Filter’ property.
- Parameters:
image_collection_for_mask (Sentinel2Collection) – Sentinel2Collection image collection to use for masking (source of pixels that will be used to mask the parent image collection)
band_name_to_mask (str) – name of the band which will be masked (target image)
band_name_for_mask (str) – name of the band to use for the mask (band which contains pixels the user wants to remove/mask from target image)
threshold (float) – threshold value where pixels less (or more, depending on mask_above) than threshold will be masked; defaults to -1.
mask_above (bool) – if True, masks pixels above the threshold; if False, masks pixels below the threshold
add_band_to_original_image (bool) – if True, adds the band used for masking to the original image as an additional band; if False, only the masked band is retained in the output image.
- Returns:
A new Sentinel2Collection with the specified band masked to pixels excluding from band_for_mask.
- Return type:
- static mask_via_singleband_image_fn(image_to_mask, image_for_mask, threshold, band_name_to_mask=None, band_name_for_mask=None, mask_above=True)
Masks pixels of interest from a specified band of a target image, based on a specified reference band and threshold. Designed for the case where the target and reference bands are in separate images. Example use case is masking vegetation from image when targeting land pixels. Can specify whether to mask pixels above or below the threshold.
- Parameters:
image_to_mask (ee.Image) – image which will be masked (target image). If multiband, only the first band will be masked.
image_for_mask (ee.Image) – image to use for the mask (image you want to remove/mask from target image). If multiband, only the first band will be used for the masked.
threshold (float) – value where pixels less or more than threshold (depending on mask_above argument) will be masked
band_name_to_mask (str, optional) – name of the band in image_to_mask to be masked. If None, the first band will be used.
band_name_for_mask (str, optional) – name of the band in image_for_mask to be used for masking. If None, the first band will be used.
mask_above (bool) – if True, masks pixels above the threshold; if False, masks pixels below the threshold.
- Returns:
masked ee.Image
- Return type:
ee.Image
- property masked_clouds_collection
Property attribute to mask clouds and return collection as class object.
- Returns:
masked Sentinel2Collection image collection.
- Return type:
- property masked_shadows_collection
Property attribute to mask shadows and return collection as class object.
- Returns:
Sentinel2Collection image collection
- Return type:
- property masked_to_water_collection
Property attribute to mask to water (mask land and cloud pixels) and return collection as class object.
- Returns:
Sentinel2Collection image collection.
- Return type:
- masked_to_water_collection_NDWI(threshold)
Function to mask to water pixels by using NDWI and return collection as class object
- Returns:
Sentinel2Collection image collection.
- Return type:
- property masked_water_collection
Property attribute to mask water and return collection as class object.
- Returns:
Sentinel2Collection image collection.
- Return type:
- masked_water_collection_NDWI(threshold)
Function to mask water by using NDWI and return collection as class object.
- Returns:
Sentinel2Collection image collection.
- Return type:
- property max
Calculates max image from image collection. Results are calculated once per class object then cached for future use.
- Returns:
max image from entire collection.
- Return type:
ee.Image
- property mean
Calculates mean image from image collection. Results are calculated once per class object then cached for future use.
- Returns:
mean image from entire collection.
- Return type:
ee.Image
- property median
Calculates median image from image collection. Results are calculated once per class object then cached for future use.
- Returns:
median image from entire collection.
- Return type:
ee.Image
- merge(collections=None, multiband_collection=None, date_key='Date_Filter')
Merge many singleband Sentinel2Collection products into the parent collection, or merge a single multiband collection with parent collection, pairing images by exact Date_Filter and returning one multiband image per date.
NOTE: if you want to merge two multiband collections, use the combine method instead.
- Parameters:
collections (list) – List of singleband collections to merge with parent collection, effectively adds one band per collection to each image in parent
multiband_collection (Sentinel2Collection, optional) – A multiband collection to merge with parent. Specifying a collection here will override collections.
date_key (str) – image property key for exact pairing (default ‘Date_Filter’)
- Returns:
parent with extra single bands attached (one image per date)
- Return type:
- property min
Calculates min image from image collection. Results are calculated once per class object then cached for future use.
- Returns:
min image from entire collection.
- Return type:
ee.Image
- property mndwi
Property attribute to calculate and access the MNDWI (Modified Normalized Difference Water Index) imagery of the Sentinel2Collection. This property initiates the calculation of MNDWI using a default threshold of -1 (or a previously set threshold of self.mndwi_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.
- Returns:
A Sentinel2Collection image collection.
- Return type:
- mndwi_collection(threshold)
Calculates mndwi and return collection as class object. Masks collection based on threshold which defaults to -1.
- Parameters:
threshold – specify threshold for MNDWI function (values less than threshold are masked).
- Returns:
Sentinel2Collection image collection.
- Return type:
- property monthly_max_collection
Creates a monthly max composite from a Sentinel2Collection image collection.
This function computes the max for each month within the collection’s date range, for each band in the collection. It automatically handles the full temporal extent of the input collection.
The resulting images have a ‘system:time_start’ property set to the first day of each month and an ‘image_count’ property indicating how many images were used in the composite. Months with no images are automatically excluded from the final collection.
NOTE: the day of month for the ‘system:time_start’ property is set to the earliest date of the first month observed and may not be the first day of the month.
- Returns:
A new Sentinel2Collection object with monthly max composites.
- Return type:
- property monthly_mean_collection
Creates a monthly mean composite from a Sentinel2Collection image collection.
This function computes the mean for each month within the collection’s date range, for each band in the collection. It automatically handles the full temporal extent of the input collection.
The resulting images have a ‘system:time_start’ property set to the first day of each month and an ‘image_count’ property indicating how many images were used in the composite. Months with no images are automatically excluded from the final collection.
NOTE: the day of month for the ‘system:time_start’ property is set to the earliest date of the first month observed and may not be the first day of the month.
- Returns:
A new Sentinel2Collection object with monthly mean composites.
- Return type:
- property monthly_median_collection
Creates a monthly median composite from a Sentinel2Collection image collection.
This function computes the median for each month within the collection’s date range, for each band in the collection. It automatically handles the full temporal extent of the input collection.
The resulting images have a ‘system:time_start’ property set to the first day of each month and an ‘image_count’ property indicating how many images were used in the composite. Months with no images are automatically excluded from the final collection.
NOTE: the day of month for the ‘system:time_start’ property is set to the earliest date of the first month observed and may not be the first day of the month.
- Returns:
A new Sentinel2Collection object with monthly median composites.
- Return type:
- property monthly_min_collection
Creates a monthly min composite from a Sentinel2Collection image collection.
This function computes the min for each month within the collection’s date range, for each band in the collection. It automatically handles the full temporal extent of the input collection.
The resulting images have a ‘system:time_start’ property set to the first day of each month and an ‘image_count’ property indicating how many images were used in the composite. Months with no images are automatically excluded from the final collection.
NOTE: the day of month for the ‘system:time_start’ property is set to the earliest date of the first month observed and may not be the first day of the month.
- Returns:
A new Sentinel2Collection object with monthly min composites.
- Return type:
- property monthly_sum_collection
Creates a monthly sum composite from a Sentinel2Collection image collection.
This function computes the sum for each month within the collection’s date range, for each band in the collection. It automatically handles the full temporal extent of the input collection.
The resulting images have a ‘system:time_start’ property set to the first day of each month and an ‘image_count’ property indicating how many images were used in the composite. Months with no images are automatically excluded from the final collection.
NOTE: the day of month for the ‘system:time_start’ property is set to the earliest date of the first month observed and may not be the first day of the month.
- Returns:
A new Sentinel2Collection object with monthly sum composites.
- Return type:
- 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.
- Returns:
LandsatCollection image collection with mosaiced imagery and mean CLOUD_COVER as a property
- Return type:
- property msavi
Property attribute to calculate and access the MSAVI (Modified Soil Adjusted Vegetation Index) imagery of the Sentinel2Collection. This property initiates the calculation of MSAVI 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.
- Returns:
A Sentinel2Collection image collection
- Return type:
- msavi_collection(threshold)
Function to calculate the MSAVI (Modified Soil Adjusted Vegetation Index) and return collection as class object, allows specifying threshold(s) for masking. This function can be called as a method but is called by default when using the msavi property attribute.
- Parameters:
threshold (float) – specify threshold for MSAVI function (values less than threshold are masked)
- Returns:
A Sentinel2Collection image collection
- Return type:
- multiband_sample(location, scale=30, file_path=None)
Extracts ALL band values for a SINGLE location across the entire collection.
- Parameters:
location (tuple or ee.Geometry) – A single (lon, lat) tuple OR ee.Geometry.
scale (int, optional) – Scale in meters. Defaults to 30.
file_path (str, optional) – Path to save CSV.
- Returns:
DataFrame indexed by Date, with columns for each Band.
- Return type:
pd.DataFrame
- multiband_zonal_stats(geometry, bands, reducer_types, scale=30, geometry_name='geom', dates=None, include_area=False, file_path=None, unweighted=False)
Calculates zonal statistics for multiple bands over a single geometry for each image in the collection. Allows for specifying different reducers for different bands. Optionally includes the geometry area.
- Parameters:
geometry (ee.Geometry or ee.Feature) – The single geometry to calculate statistics for.
bands (list of str) – A list of band names to include in the analysis.
reducer_types (str or list of str) – A single reducer name (e.g., ‘mean’) to apply to all bands, or a list of reducer names matching the length of the ‘bands’ list to apply specific reducers to specific bands.
scale (int, optional) – The scale in meters for the reduction. Defaults to 30.
geometry_name (str, optional) – A name for the geometry, used in column naming. Defaults to ‘geom’.
dates (list of str, optional) – A list of date strings (‘YYYY-MM-DD’) to filter the collection. Defaults to None (processes all images).
include_area (bool, optional) – If True, adds a column with the area of the geometry in square meters. Defaults to False.
file_path (str, optional) – If provided, saves the resulting DataFrame to a CSV file at this path.
unweighted (bool, optional) – Whether to use unweighted reducers. Defaults to False.
- Returns:
A pandas DataFrame indexed by Date, with columns named as ‘{band}_{geometry_name}_{reducer}’.
- Return type:
pd.DataFrame
- property nbr
Property attribute to calculate and access the NBR (Normalized Burn Ratio) imagery of the Sentinel2Collection. This property initiates the calculation of NBR 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.
- Returns:
A Sentinel2Collection image collection
- Return type:
- nbr_collection(threshold)
Function to calculate the NBR (Normalized Burn Ratio) and return collection as class object, allows specifying threshold(s) for masking. This function can be called as a method but is called by default when using the nbr property attribute.
- Parameters:
threshold (float) – specify threshold for NBR function (values less than threshold are masked)
- Returns:
A Sentinel2Collection image collection
- Return type:
- property ndmi
Property attribute to calculate and access the NDMI (Normalized Difference Moisture Index) imagery of the Sentinel2Collection. This property initiates the calculation of NDMI 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.
- Returns:
A Sentinel2Collection image collection
- Return type:
- ndmi_collection(threshold)
Function to calculate the NDMI (Normalized Difference Moisture Index) and return collection as class object, allows specifying threshold(s) for masking. This function can be called as a method but is called by default when using the ndmi property attribute.
- Parameters:
threshold (float) – specify threshold for NDMI function (values less than threshold are masked)
- Returns:
A Sentinel2Collection image collection
- Return type:
- property ndsi
Property attribute to calculate and access the NDSI (Normalized Difference Snow Index) imagery of the Sentinel2Collection. This property initiates the calculation of NDSI 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.
- Returns:
A Sentinel2Collection image collection
- Return type:
- ndsi_collection(threshold)
Function to calculate the NDSI (Normalized Difference Snow Index) and return collection as class object, allows specifying threshold(s) for masking. This function can be called as a method but is called by default when using the ndsi property attribute.
- Parameters:
threshold (float) – specify threshold for NDSI function (values less than threshold are masked)
- Returns:
A Sentinel2Collection image collection
- Return type:
- 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.
- Returns:
A Sentinel2Collection image collection.
- Return type:
- ndvi_collection(threshold)
Calculates ndvi and return collection as class object. Masks collection based on threshold which defaults to -1.
- Parameters:
threshold – specify threshold for NDVI function (values less than threshold are masked).
- Returns:
Sentinel2Collection image collection.
- Return type:
- 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.
- Returns:
A Sentinel2Collection image collection.
- Return type:
- ndwi_collection(threshold)
Calculates ndwi and return collection as class object. Masks collection based on threshold which defaults to -1.
- Parameters:
threshold – specify threshold for NDWI function (values less than threshold are masked).
- Returns:
Sentinel2Collection image collection.
- Return type:
- static pixelAreaSum(image, band_name, geometry, threshold=-1, scale=10, maxPixels=1000000000000.0)
Calculates 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). If multiple band names are provided in a list, the function will calculate area for each band in the list and store each as a separate property.
NOTE: The resulting value has units of square meters.
- Parameters:
image (ee.Image) – input ee.Image
band_name (string or list of strings) – name of band(s) (string) for calculating area. If providing multiple band names, pass as a list of strings.
geometry (ee.Geometry) – ee.Geometry object denoting area to clip to for area calculation
threshold (float) – integer threshold to specify masking of pixels below threshold (defaults to -1). If providing multiple band names, the same threshold will be applied to all bands. Best practice in this case is to mask the bands prior to passing to this function and leave threshold at default of -1.
scale (int) – integer scale of image resolution (meters) (defaults to 10)
maxPixels (int) – integer denoting maximum number of pixels for calculations
- Returns:
ee.Image with area calculation in square meters stored as property matching name of band
- Return type:
ee.Image
- pixelAreaSumCollection(band_name, geometry, threshold=-1, scale=10, maxPixels=1000000000000.0, output_type='ImageCollection', area_data_export_path=None)
Calculates the geodesic summation of area for pixels of interest (above a specific threshold) within a geometry and stores the value as an image property (matching name of chosen band) for an entire image collection. Optionally exports the area data to a CSV file.
NOTE: The resulting value has units of square meters.
- Parameters:
band_name (string or list of strings) – name of band(s) (string) for calculating area. If providing multiple band names, pass as a list of strings.
geometry (ee.Geometry) – ee.Geometry object denoting area to clip to for area calculation.
threshold (float) – integer threshold to specify masking of pixels below threshold (defaults to -1). If providing multiple band names, the same threshold will be applied to all bands. Best practice in this case is to mask the bands prior to passing to this function and leave threshold at default of -1.
scale (int) – integer scale of image resolution (meters) (defaults to 30).
maxPixels (int) – integer denoting maximum number of pixels for calculations.
output_type (str) – ‘ImageCollection’ or ‘ee.ImageCollection’ to return an ee.ImageCollection, ‘Sentinel2Collection’ to return a Sentinel2Collection object, or ‘DataFrame’, ‘Pandas’, ‘pd’, ‘dataframe’, ‘df’ to return a pandas DataFrame (defaults to ‘ImageCollection’).
area_data_export_path (str, optional) – If provided, the function will save the resulting area data to a CSV file at the specified path.
- Returns:
Image collection of images with area calculation (square meters) stored as property matching name of band. Type of output depends on output_type argument.
- Return type:
ee.ImageCollection or Sentinel2Collection
- remove_duplicate_dates(sort_by='system:time_start', ascending=True)
Removes duplicate images that share the same date, keeping only the first one encountered. Useful for handling duplicate Sentinel-2A/2B acquisitions or overlapping path/rows.
- Parameters:
sort_by (str) – Property to sort by before filtering distinct dates. Defaults to ‘system:time_start’. Recommended to use ‘CLOUDY_PIXEL_PERCENTAGE’ (ascending=True) to keep the clearest image.
ascending (bool) – Sort order. Defaults to True.
- Returns:
A new Sentinel2Collection object with distinct dates.
- Return type:
- sample(locations, band=None, scale=None, location_names=None, dates=None, file_path=None, tileScale=1)
Extracts time-series pixel values for a list of locations.
- Parameters:
locations (list, tuple, ee.Geometry, or ee.FeatureCollection) – Input points.
band (str, optional) – The name of the band to sample. Defaults to the first band.
scale (int, optional) – Scale in meters. Defaults to 30 if None.
location_names (list of str, optional) – Custom names for locations.
dates (list, optional) – Date filter [‘YYYY-MM-DD’].
file_path (str, optional) – CSV export path.
tileScale (int, optional) – Aggregation tile scale. Defaults to 1.
- Returns:
DataFrame indexed by Date, columns by Location.
- Return type:
pd.DataFrame (or CSV if file_path is provided)
- property savi
Property attribute to calculate and access the SAVI (Soil Adjusted Vegetation Index) imagery of the Sentinel2Collection. This property initiates the calculation of SAVI 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.
- Returns:
A Sentinel2Collection image collection
- Return type:
- savi_collection(threshold, l=0.5)
Function to calculate the SAVI (Soil Adjusted Vegetation Index) and return collection as class object, allows specifying threshold(s) for masking. This function can be called as a method but is called by default when using the savi property attribute.
- Parameters:
threshold (float) – specify threshold for SAVI function (values less than threshold are masked)
l (float, optional) – Soil brightness correction factor, typically set to 0.5 for intermediate vegetation cover. Defaults to 0.5.
- Returns:
A Sentinel2Collection image collection
- Return type:
- property scale_to_reflectance
Scales each band in the Sentinel-2 collection from DN values to surface reflectance values.
- Returns:
A new Sentinel2Collection object with bands scaled to reflectance.
- Return type:
- sens_slope_trend(target_band=None, join_method='system:time_start', geometry=None)
Calculates Sen’s Slope (trend magnitude) for the collection. This is a lighter-weight alternative to the full mann_kendall_trend function if only the direction and magnitude of the trend are needed.
Be sure to select the correct band for the target_band parameter, as this will be used to calculate the trend statistics. You may optionally provide an ee.Geometry object for the geometry parameter to limit the area over which the trend statistics are calculated. The geometry parameter is optional and defaults to None, which means that the trend statistics will be calculated over the entire footprint of the image collection.
- Parameters:
target_band (str) – The name of the band to analyze. Defaults to ‘ndvi’.
join_method (str) – Property to use for time sorting (‘system:time_start’ or ‘Date_Filter’).
geometry (ee.Geometry, optional) – Geometry to mask the final output.
- Returns:
An image containing the ‘slope’ band.
- Return type:
ee.Image
- static sentinel_broadband_albedo_fn(image, snow_free=True)
Calculates broadband albedo for Sentinel-2 images, based on Li et al., 2018 (https://doi.org/10.1016/j.rse.2018.08.025) for snow-free or snow-included conditions.
- Parameters:
image (ee.Image) – input ee.Image
snow_free (bool) – If True, calculates albedo for snow-free conditions. If False, calculates for snow-included conditions.
- Returns:
broadband albedo ee.Image
- Return type:
ee.Image
- Raises:
ValueError – if snow_free argument is not True or False
- static sentinel_chlorophyll_fn(image, threshold)
Calculates 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.
- Parameters:
image (ee.Image) – input image
threshold (float) – value between -1 and 1 where pixels less than threshold will be masked.
- Returns:
chlorophyll-a ee.Image
- Return type:
ee.Image
- static sentinel_evi_fn(image, threshold, gain_factor=2.5, l=1, c1=6, c2=7.5)
Calculates the Enhanced Vegetation Index (EVI) for Sentinel-2 images. Masks image based on threshold.
- Parameters:
image (ee.Image) – input ee.Image
threshold (float) – value between -1 and 1 where EVI pixels less than threshold will be masked.
gain_factor (float, optional) – Gain factor, typically set to 2.5. Defaults to 2.5.
l (float, optional) – Canopy background adjustment factor, typically set to 1. Defaults to 1.
c1 (float, optional) – Coefficient for the aerosol resistance term, typically set to 6. Defaults to 6.
c2 (float, optional) – Coefficient for the aerosol resistance term, typically set to 7.5. Defaults to 7.5.
- Returns:
EVI ee.Image
- Return type:
ee.Image
- static sentinel_gypsum_fn(image, threshold)
Calculates multispectral gypsum index for Sentinel2 imagery and mask image based on threshold.
- Parameters:
image (ee.Image) – input image
threshold (float) – value between -1 and 1 where pixels less than threshold will be masked.
- Returns:
gypsum ee.Image
- Return type:
ee.Image
- static sentinel_halite_fn(image, threshold)
Calculates multispectral halite index for Sentinel2 imagery and mask image based on threshold.
- Parameters:
image (ee.Image) – input image
threshold (float) – value between -1 and 1 where pixels less than threshold will be masked.
- Returns:
halite ee.Image
- Return type:
ee.Image
- static sentinel_mndwi_fn(image, threshold)
Calculates mndwi from GREEN and SWIR bands for Sentinel-2 imagery and masks image based on threshold.
- Parameters:
image (ee.Image) – input image
threshold (float) – value between -1 and 1 where pixels less than threshold will be masked.
- Returns:
mndwi ee.Image
- Return type:
ee.Image
- static sentinel_msavi_fn(image, threshold)
Calculates the Modified Soil-Adjusted Vegetation Index (MSAVI) for Sentinel-2 images. Masks image based on threshold. See Qi et al., 1994 - https://doi.org/10.1016/0034-4257(94)90134-1
- Parameters:
image (ee.Image) – input ee.Image
threshold (float) – value between -1 and 1 where MSAVI pixels less than threshold will be masked
- Returns:
MSAVI ee.Image
- Return type:
ee.Image
- static sentinel_nbr_fn(image, threshold)
Calculates the Normalized Burn Ratio (NBR) for Sentinel-2 images. Masks image based on threshold.
- Parameters:
image (ee.Image) – input ee.Image
threshold (float) – value between -1 and 1 where NBR pixels less than threshold will be masked.
- Returns:
NBR ee.Image
- Return type:
ee.Image
- static sentinel_ndmi_fn(image, threshold)
Calculates the Normalized Difference Moisture Index (NDMI) for Sentinel-2 images. Masks image based on threshold. See Wilson & Sader, 2002 - https://doi.org/10.1016/S0034-4257(02)00074-7
- Parameters:
image (ee.Image) – input ee.Image
threshold (float) – value between -1 and 1 where NDMI pixels less than threshold will be masked
- Returns:
NDMI ee.Image
- Return type:
ee.Image
- static sentinel_ndsi_fn(image, threshold)
Calculates the Normalized Difference Snow Index (NDSI) for Sentinel2 images. Masks image based on threshold.
- Parameters:
image (ee.Image) – input ee.Image
threshold (float) – value between -1 and 1 where NDSI pixels greater than threshold will be masked.
- Returns:
NDSI ee.Image
- Return type:
ee.Image
- static sentinel_ndvi_fn(image, threshold)
Calculates ndvi for for Sentinel2 imagery and mask image based on threshold.
- Parameters:
image (ee.Image) – input image
threshold (float) – value between -1 and 1 where pixels less than threshold will be masked.
- Returns:
ndvi ee.Image
- Return type:
ee.Image
- static sentinel_ndwi_fn(image, threshold)
Calculates ndwi from GREEN and NIR bands (McFeeters, 1996 - https://doi.org/10.1080/01431169608948714) for Sentinel2 imagery and masks image based on threshold.
- Parameters:
image (ee.Image) – input image
threshold (float) – value between -1 and 1 where pixels less than threshold will be masked.
- Returns:
ndwi ee.Image
- Return type:
ee.Image
- static sentinel_savi_fn(image, threshold, l=0.5)
Calculates the Soil-Adjusted Vegetation Index (SAVI) for Sentinel2 images. Masks image based on threshold. See Huete, 1988 - https://doi.org/10.1016/0034-4257(88)90106-X
- Parameters:
image (ee.Image) – input ee.Image
threshold (float) – value between -1 and 1 where SAVI pixels less than threshold will be masked.
l (float, optional) – Soil brightness correction factor, typically set to 0.5. Defaults to 0.5.
- Returns:
SAVI ee.Image
- Return type:
ee.Image
- static sentinel_turbidity_fn(image, threshold)
Calculates Normalized Difference Turbidity Index (NDTI; Lacaux et al., 2007) for for Sentinel2 imagery and mask image based on threshold.
- Parameters:
image (ee.Image) – input image
threshold (float) – value between -1 and 1 where pixels less than threshold will be masked.
- Returns:
turbidity ee.Image
- Return type:
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.
- Parameters:
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:
organized list of values along the transect(s)
- Return type:
pd.DataFrame or ee.FeatureCollection
- transect_iterator(lines, line_names, reducer='mean', dist_interval=30, n_segments=None, scale=10, processing_mode='aggregated', save_folder_path=None, sampling_method='line', point_buffer_radius=15, batch_size=10)
Computes and returns pixel values along transects. Provide a list of ee.Geometry.LineString objects and corresponding names, and the function will compute the specified reducer value at regular intervals along each line for all images in the collection. Use dist_interval or n_segments to control sampling resolution. The user can choose between ‘aggregated’ mode (returns a dictionary of DataFrames) or ‘iterative’ mode (saves individual CSVs for each transect). Alter sampling_method to sample directly along the line or via buffered points along the line. Buffered points can help capture more representative pixel values in heterogeneous landscapes, and the buffer radius can be adjusted via point_buffer_radius.
- Parameters:
lines (list) – List of ee.Geometry.LineString objects.
line_names (list) – List of string names for each transect.
reducer (str, optional) – Reducer name. Defaults to ‘mean’.
dist_interval (float, optional) – Distance interval in meters. Defaults to 30.
n_segments (int, optional) – Number of segments (overrides dist_interval).
scale (int, optional) – Scale in meters. Defaults to 10.
processing_mode (str, optional) – ‘aggregated’ or ‘iterative’.
save_folder_path (str, optional) – Path to save CSVs.
sampling_method (str, optional) – ‘line’ or ‘buffered_point’.
point_buffer_radius (int, optional) – Buffer radius if using ‘buffered_point’.
batch_size (int, optional) – Images per request in ‘aggregated’ mode. Defaults to 10. Lower the value if you encounter a ‘Too many aggregations’ error.
- Returns:
Dictionary of DataFrames (aggregated) or None (iterative).
- Return type:
dict or None
- 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.
- Returns:
A Sentinel2Collection image collection.
- Return type:
- turbidity_collection(threshold)
Calculates NDTI turbidity index and return collection as class object. Masks collection based on threshold which defaults to -1.
- Parameters:
threshold – specify threshold for NDTI function (values less than threshold are masked).
- Returns:
Sentinel2Collection image collection.
- Return type:
- yearly_max_collection(start_month=1, end_month=12)
Creates a yearly max composite from the collection, with optional monthly filtering.
This function computes the max for each year within the collection’s date range. You can specify a range of months (e.g., start_month=6, end_month=10 for June-October) to calculate the max only using imagery from that specific season for each year. The resulting images have ‘system:time_start’, ‘year’, ‘image_count’, ‘season_start’, ‘season_end’, and ‘Date_Filter’ properties. Years with no images (after filtering) are excluded.
- Parameters:
start_month (int) – The starting month (1-12) for the filter. Defaults to 1 (January).
end_month (int) – The ending month (1-12) for the filter. Defaults to 12 (December).
- Returns:
A new instance of the same class (e.g., Sentinel2Collection) containing the yearly max composites.
- Return type:
Object
- yearly_mean_collection(start_month=1, end_month=12)
Creates a yearly mean composite from the collection, with optional monthly filtering.
This function computes the mean for each year within the collection’s date range. You can specify a range of months (e.g., start_month=6, end_month=10 for June-October) to calculate the mean only using imagery from that specific season for each year.
The resulting images have ‘system:time_start’, ‘year’, ‘image_count’, ‘season_start’, ‘season_end’, and ‘Date_Filter’ properties. Years with no images (after filtering) are excluded.
- Parameters:
start_month (int) – The starting month (1-12) for the filter. Defaults to 1 (January).
end_month (int) – The ending month (1-12) for the filter. Defaults to 12 (December).
- Returns:
A new instance of the same class (e.g., Sentinel2Collection) containing the yearly mean composites.
- Return type:
Object
- yearly_median_collection(start_month=1, end_month=12)
Creates a yearly median composite from the collection, with optional monthly filtering.
This function computes the median for each year within the collection’s date range. You can specify a range of months (e.g., start_month=6, end_month=10 for June-October) to calculate the median only using imagery from that specific season for each year. The resulting images have ‘system:time_start’, ‘year’, ‘image_count’, ‘season_start’, ‘season_end’, and ‘Date_Filter’ properties. Years with no images (after filtering) are excluded.
- Parameters:
start_month (int) – The starting month (1-12) for the filter. Defaults to 1 (January).
end_month (int) – The ending month (1-12) for the filter. Defaults to 12 (December).
- Returns:
A new instance of the same class (e.g., Sentinel2Collection) containing the yearly median composites.
- Return type:
Object
- yearly_min_collection(start_month=1, end_month=12)
Creates a yearly min composite from the collection, with optional monthly filtering.
This function computes the min for each year within the collection’s date range. You can specify a range of months (e.g., start_month=6, end_month=10 for June-October) to calculate the min only using imagery from that specific season for each year. The resulting images have ‘system:time_start’, ‘year’, ‘image_count’, ‘season_start’, ‘season_end’, and ‘Date_Filter’ properties. Years with no images (after filtering) are excluded.
- Parameters:
start_month (int) – The starting month (1-12) for the filter. Defaults to 1 (January).
end_month (int) – The ending month (1-12) for the filter. Defaults to 12 (December).
- Returns:
A new instance of the same class (e.g., Sentinel2Collection) containing the yearly min composites.
- Return type:
Object
- yearly_sum_collection(start_month=1, end_month=12)
Creates a yearly sum composite from the collection, with optional monthly filtering.
This function computes the sum for each year within the collection’s date range. You can specify a range of months (e.g., start_month=6, end_month=10 for June-October) to calculate the sum only using imagery from that specific season for each year. The resulting images have ‘system:time_start’, ‘year’, ‘image_count’, ‘season_start’, ‘season_end’, and ‘Date_Filter’ properties. Years with no images (after filtering) are excluded.
- Parameters:
start_month (int) – The starting month (1-12) for the filter. Defaults to 1 (January).
end_month (int) – The ending month (1-12) for the filter. Defaults to 12 (December).
- Returns:
A new instance of the same class (e.g., Sentinel2Collection) containing the yearly sum composites.
- Return type:
Object