statgis.gee.time_series_analysis#
Functions to process image collections as time series
Module Contents#
Functions#
|
Extract dates from all images in an image collection. |
|
Function to resample an Image Collection to a fixed timestamp. |
|
Calculate the linear trend and seasonality of an image collection. |
|
Seasonal decomposition using the linear trend. This function take an image collection |
- statgis.gee.time_series_analysis.extract_dates(image_collection: ee.ImageCollection) pandas.DatetimeIndex#
Extract dates from all images in an image collection.
- Parameters:
image_collection (ee.ImageCollection) – Collection of image.
- Returns:
dates – Series with the dates of the images.
- Return type:
pd.Series
Example
>>> import ee >>> from statgis.gee import time_series_analysis >>> ee.Initialize() >>> chirps = ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY").filterDate("1985-01-01", "2022-12-31") >>> dates = time_series_analysis.extract_dates(chirps)
- statgis.gee.time_series_analysis.resample(image_collection: ee.ImageCollection, reducer: ee.Reducer, scale: str) ee.ImageCollection#
Function to resample an Image Collection to a fixed timestamp.
- Parameters:
image_collection (ee.ImageCollection) – Image Collection to resample.
reducer (ee.Reducer) – To aggregate the images
scale (str) – Time scale to aggregate the image, must be one from: - annual. - monthly. - monthly-stat. - monthly-stat-repeated.
- Returns:
final_collection – Collection resampled.
- Return type:
ee.ImageCollection
Example
>>> import ee >>> from statgis.gee import time_series_analysis >>> ee.Initialize() >>> chirps = ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY").filterDate("1985-01-01", "2022-12-31") >>> annual_precipitation = time_series_analysis.resample(chirps, ee.Reducer.sum(), "annual")
- statgis.gee.time_series_analysis.detrend(image_collection: ee.ImageCollection, band: str, restore_mean: bool = True) ee.ImageCollection#
Calculate the linear trend and seasonality of an image collection.
- Parameters:
image_collection (ee.ImageCollection) – Image collection to remove its trend.
band (str) – Band of interest.
restore_mean (bool = True) – If True, the data mean wil lbe restored in the seasonality.
- Returns:
image_collection – Image collection with linear trend and seasonality.
- Return type:
ee.ImageCollection
Example
>>> import ee >>> from statgis.gee import time_series_analysis >>> ee.Initialize() >>> chirps = ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY").filterDate("1985-01-01", "2022-12-31") >>> annual_precipitation = time_series_analysis.resample(chirps, ee.Reducer.sum(), "annual") >>> seasonal_precipitation = time_series_analysis.detrend(annual_precipitation, "precipitation")
- statgis.gee.time_series_analysis.seasonal_decompose(image_collection: ee.ImageCollection, band: str, restore_mean: bool = True) ee.ImageCollection#
Seasonal decomposition using the linear trend. This function take an image collection and extract the time series components in the specified band.
- Parameters:
image_collection (ee.ImageCollection) – Image collection of interest.
band (str) – Band of interest.
restore_mean (bool = True) – If True, the data mean wil lbe restored in the seasonality.
- Returns:
final_collection – Image collection with time series components.
- Return type:
ee.ImageCollection
Example
>>> import ee >>> from statgis.gee import time_series_analysis >>> ee.Initialize() >>> chirps = ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY").filterDate("1985-01-01", "2022-12-31") >>> monthly_precipitation = time_series_analysis.resample(chirps, ee.Reducer.sum(), "monthly") >>> precipitation_ts = time_series_analysis.seasonal_decompose(monthly_precipitation, "precipitation")