:py:mod:`ecoscope.io.eetools` ============================= .. py:module:: ecoscope.io.eetools Module Contents --------------- .. py:data:: logger .. py:data:: ee_is_initialized :value: False .. py:data:: ee_initialization_expires .. py:data:: ee_initialization_ttl .. py:data:: colourPalettes .. py:function:: initialize_earthengine(key_dict) 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. .. py:function:: convert_millisecs_datetime(unix_time) .. py:function:: add_img_time(img) A function to add the date range of the image as one of its properties and the start and end values as new bands .. py:function:: label_gdf_with_img(gdf=None, img=None, region_reducer=None, scale=500.0) .. py:function:: _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) 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 .. py:function:: 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) .. py:function:: 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) .. py:function:: chunk_gdf(gdf=None, label_func=None, label_func_kwargs=None, df_chunk_size=25000, max_workers=1) A function that will process the input gdf in chunks and apply the input label_func function over the chunks. :param 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. :param label_func: a function to run on the EE cloud that has the signature (feat, kwargs) :param label_func_kwargs: a dictionary of parameters to provide to the label_func :param df_chunk_size: how many features (rows) to process at once within EE :param max_workers: the number of chunks to process concurrently :return: a dataframe with the same index as the input gdf and where each pixel value (or reduced value) is a row .. py:function:: calculate_anomaly(gdf=None, img_coll=None, historical_start='2000-01-01', start='2010-01-01', end='2022-01-01', scale=5000.0) 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