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.convert_millisecs_datetime(unix_time)[source]#
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=None, time_col='', img_coll=None, output_col_name=None, stack_limit_before=1, stack_limit_after=1)[source]#

A function that will add a column to a gdf (output_col_name) that contains the stack_limit_before -> stack_limit_after temporally closest image IDs from an image collection. :param gdf: :param time_col: :param img_coll: :param output_col_name: :param stack_limit_before: :param stack_limit_after: :return: None

ecoscope.io.eetools.label_gdf_with_temporal_image_collection_by_feature(gdf=None, time_col_name=None, stack_limit_before=1, stack_limit_after=1, 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