satellitetools.gee

Module to retrieve Sentinel-2 data from Google Earth Engine (GEE).

@author: Olli Nevalainen,

Finnish Meteorological Institute)

Attributes

logger

GEE_NO_DATA

GEE_DATASET

GEE_SCL_BAND

Classes

GEESentinel2DataCollection

Class to retrieve Sentinel-2 data from Google Earth Engine (GEE).

MultiGEESentinel2DataCollection

Class to retrieve Sentinel-2 data from Google Earth Engine (GEE) for

Functions

gee_lists_to_2D_array(→ Tuple[numpy.ndarray, ...)

Convert 1D lists of coordinates and corresponding values to 2D array.

get_copernicus_dem_elevation(lat, lon)

Get elevation from Copernicus DEM.

ee_get_s2_quality_info(→ Dict[str, pandas.DataFrame])

Get S2 quality information from GEE.

ee_get_s2_data(→ Dict[str, pandas.DataFrame])

Get S2 data (level L2A, bottom of atmosphere data) from GEE.

Module Contents

satellitetools.gee.logger[source]
satellitetools.gee.GEE_NO_DATA = -99999[source]
satellitetools.gee.GEE_DATASET = 'COPERNICUS/S2_SR_HARMONIZED'[source]
satellitetools.gee.GEE_SCL_BAND[source]
class satellitetools.gee.GEESentinel2DataCollection(aoi: satellitetools.common.classes.AOI, req_params: satellitetools.common.sentinel2.Sentinel2RequestParams)[source]

Bases: satellitetools.common.sentinel2.Sentinel2DataCollection

Class to retrieve Sentinel-2 data from Google Earth Engine (GEE).

aoi

Area of interest.

Type:

AOI

req_params

Request parameters.

Type:

Sentinel2RequestParams

Initialize GEESentinel2DataCollection object.

Parameters:
create_s2_items(feature: Dict)[source]

Create Sentinel-2 items from GEE feature.

Parameters:

feature (dict) – Feature dictionary from GEE.

create_s2_items_from_quality_information()[source]

Create Sentinel-2 items from quality information.

set_s2_item_data(feature: Dict)[source]

Set Sentinel-2 item data from GEE feature.

Parameters:

feature (dict) – Feature dictionary from GEE.

get_s2_item_with_productid(productid: str) satellitetools.common.sentinel2.Sentinel2Item | None[source]

Get Sentinel-2 item with productid.

Parameters:

productid (str) – Sentinel-2 product ID.

Returns:

s2_item – Sentinel-2 item.

Return type:

Union[Sentinel2Item, None]

drop_s2_item_with_productid(productid: str)[source]

Drop Sentinel-2 item with productid.

Parameters:

productid (str) – Sentinel-2 product ID.

get_ee_geometry(shapely_geometry: shapely.Geometry) ee.Geometry[source]

Get Earth Engine geometry from Shapely geometry.

Parameters:

shapely_geometry (shapely.Geometry) – Shapely geometry.

Returns:

ee_geometry – Earth Engine geometry.

Return type:

ee.Geometry

ee_feature_from_s2_items() ee.Feature[source]

Create GEE feature from Sentinel-2 items.

Returns:

feature – GEE feature.

Return type:

ee.Feature

ee_feature_from_aoi() ee.Feature[source]

Create GEE feature from AOI.

Returns:

feature – GEE feature.

Return type:

ee.Feature

get_quality_info()[source]

Get quality information from GEE.

get_s2_data()[source]

Get S2 data (level L2A, bottom of atmosphere data) from GEE.

search_s2_items()[source]
class satellitetools.gee.MultiGEESentinel2DataCollection(aois: List[satellitetools.common.classes.AOI], req_params: satellitetools.common.sentinel2.Sentinel2RequestParams)[source]

Class to retrieve Sentinel-2 data from Google Earth Engine (GEE) for multiple AOIs.

aois

List of AOIs.

Type:

List[AOI]

req_params[source]

Request parameters.

Type:

Sentinel2RequestParams

Initialize MultiGEESentinel2DataCollection object.

Parameters:
data_collections[source]
req_params[source]
ee_search_s2_products()[source]
ee_get_s2_quality_info()[source]

Get S2 quality information from GEE.

ee_get_s2_data()[source]

Get S2 data (level L2A, bottom of atmosphere data) from GEE.

Warning! All bands are resampled to resolution specified by req_params.target_gsd.

satellitetools.gee.gee_lists_to_2D_array(x_coords: numpy.ndarray | list, y_coords: numpy.ndarray | list, data: numpy.ndarray | list, no_data: float) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]

Convert 1D lists of coordinates and corresponding values to 2D array.

Parameters:
  • x_coords (Union[np.ndarray, list]) – X coordinates.

  • y_coords (Union[np.ndarray, list]) – Y coordinates.

  • data (Union[np.ndarray, list]) – Data values.

  • no_data (float) – No data value.

Returns:

  • x_vals (np.ndarray) – X values.

  • y_vals (np.ndarray) – Y values.

  • arr (np.ndarray) – 2D array of data values.

satellitetools.gee.get_copernicus_dem_elevation(lat: float, lon: float)[source]

Get elevation from Copernicus DEM.

Parameters:
  • lat (float) – Latitude.

  • lon (float) – Longitude.

Returns:

elevation – Elevation.

Return type:

float

satellitetools.gee.ee_get_s2_quality_info(aois: str | List[satellitetools.common.classes.AOI], req_params: satellitetools.common.sentinel2.Sentinel2RequestParams) Dict[str, pandas.DataFrame][source]

Get S2 quality information from GEE.

Parameters:
Returns:

quality_dict – Quality information.

Return type:

Dict[str, pd.DataFrame]

satellitetools.gee.ee_get_s2_data(aois: str | List[satellitetools.common.classes.AOI], req_params: satellitetools.common.sentinel2.Sentinel2RequestParams, quality_dict: Dict[str, pandas.DataFrame], qi_threshold: float = 0, qi_filter: List[satellitetools.common.sentinel2.SCLClass] = S2_FILTER1) Dict[str, pandas.DataFrame][source]

Get S2 data (level L2A, bottom of atmosphere data) from GEE.

Parameters:
  • aois (Union[str, List[AOI]]) – Area of interest.

  • req_params (Sentinel2RequestParams) – Request parameters.

  • quality_dict (Dict[str, pd.DataFrame]) – Quality information.

  • qi_threshold (float, optional) – Quality index threshold, by default 0.

  • qi_filter (List[SCLClass], optional) – Quality index filter, by default S2_FILTER1.

Returns:

data_dict – Data.

Return type:

Dict[str, pd.DataFrame]