ecoscope.io.eetools#
Module Contents#
- ecoscope.io.eetools.logger#
- ecoscope.io.eetools.ee_is_initialized = False#
- ecoscope.io.eetools.ee_initialization_expires#
- ecoscope.io.eetools.ee_initialization_ttl#
- ecoscope.io.eetools.colourPalettes#
- ecoscope.io.eetools.initialize_earthengine(key_dict)[source]#
This takes a JSON key as a dict. :param key_dict: :return: a credentials object that can be used to initialize the earth engine library.
- ecoscope.io.eetools.add_img_time(img)[source]#
A function to add the date range of the image as one of its properties and the start and end values as new bands
- ecoscope.io.eetools.label_gdf_with_img(gdf=None, img=None, region_reducer=None, scale=500.0)[source]#
- ecoscope.io.eetools._match_gdf_to_img_coll_ids(gdf, time_col, img_coll, output_col_name='img_ids', n_before=1, n_after=1, n='images')[source]#
A function that will add a column to a gdf (output_col_name) that contains the n_before -> n_after temporally closest image IDs from an image collection.
- Parameters:
gdf (geopandas.GeoDataFrame) – The GeoDataFrame to add image IDs to
time_col (str) – The name of the column within the given gdf containing the relevant timestamps
img_coll (ee.ImageCollection) – The image collection to lookup image IDs from
output_col_name (str, optional) – The name of the column to be added to the given gdf, default is ‘img_ids’
n_before (int, optional) – The number of n days/weeks/images before to grab image IDs for, default is 1
n_after (int, optional) – The number of n days/weeks/images after to grab image IDs for, default is 1
n (str, optional) – One of: ‘images’(default), ‘microseconds’, ‘milliseconds’ ‘seconds’, ‘minutes’, ‘hours’, ‘days’ or ‘weeks’ If n is ‘images’, this appends n_before IDs + the temporally closest ID + n_after IDs Otherwise this appends image IDs between timestamp-n_before to timestamp+n_after where timestamp is a given row from the input gdf
- ecoscope.io.eetools.label_gdf_with_temporal_image_collection_by_feature(gdf=None, time_col_name=None, n_before=1, n_after=1, n='images', img_coll=None, region_reducer=None, scale=500.0)[source]#
- ecoscope.io.eetools.label_gdf_with_temporal_image_collection_by_timespan(gdf=None, img_coll=None, image_radius=0, add_time=False, region_reducer='toList', df_chunk_size=25000, max_workers=1)[source]#
- ecoscope.io.eetools.chunk_gdf(gdf=None, label_func=None, label_func_kwargs=None, df_chunk_size=25000, max_workers=1)[source]#
A function that will process the input gdf in chunks and apply the input label_func function over the chunks.
- Parameters:
gdf – a geopandas dataframe. The ‘geometry’ column can be any type pf geometry (point/line/polygon). The gdf needs to have a column with the name of the image_collection and the column values are lists of the individual image IDs that need to be associated with each feature. This step will typically be run with the match_img_coll_ids_to_gdf() function beforehand.
label_func – a function to run on the EE cloud that has the signature (feat, kwargs)
label_func_kwargs – a dictionary of parameters to provide to the label_func
df_chunk_size – how many features (rows) to process at once within EE
max_workers – the number of chunks to process concurrently
- Returns:
a dataframe with the same index as the input gdf and where each pixel value (or reduced value) is a row
- ecoscope.io.eetools.calculate_anomaly(gdf=None, img_coll=None, historical_start='2000-01-01', start='2010-01-01', end='2022-01-01', scale=5000.0)[source]#
Compute anomalies by subtracting the historical_start mean from each image in a collection of start->end images. :param gdf: the input geodataframe :param img_coll: the input EE image collection :param historical_start: start time for calculating the mean reference :param start: end time for mean reference and the start time for the anomaly calculation :param end: end time for the anomaly calculation :param scale: the image scale :return: a dataframe with same index as input gdf with the img_dates and the anomaly calculation