scripts/download_sen12.py
def makeImageCollection(ee_dir, ee_roi, start_date, end_date, filters_before=None, modifiers=[], filters_after=None):
    '''
    Queries for Google Earth Engine (GEE) images based off of the input values. See below for details.
    Outputs a GEE ImageCollection object.

    The following arguments are required--

    "ee_dir": The GEE directory you want to pull images from. For example, to get Sentinel-2 L2A images,
              input "COPERNICUS/S2_SR".

    "ee_roi": A GEE Geometry Polygon object specifying the bounds of the image query.

    "start_date": A string containing the first date of the date range you want your images to be from;
                  e.g., "2020-10-30".

    "end_date": A string containing the last date of the date range you want your images to be from.

    The following arguments are optional--

    "filters_before": A list of ee.Filter objects you want to apply to the ImageCollection *before* the modifiers
                      are applied. Default is None.
    
    "modifiers": A list of functions to map onto the ImageCollection using GEE's ".map()" method. Each function
                 must have as its input and output only a single GEE Image object. All functions will be applied
                 to all the Images in the ImageCollection. Defaults to an empty list.

    "filters_after": A list of ee.Filter objects you want to apply to the ImageCollection *after* the modifiers
                     are applied. Default is None.
    '''
    ## Split into the original call/filters and the mapping
    
    #print(modifiers)

    collection = ee.ImageCollection(ee_dir) \
                .filterDate(ee.Date(start_date), ee.Date(end_date)) \
                .filterBounds(ee_roi) \
                .map( lambda x: clipToROI(x, ee.Geometry(ee_roi)) )

    #print("size of collection:",collection.size().getInfo())

    if filters_before is not None:
        collection = collection.filter( filters_before )
    
    for m in modifiers:
        #print(f'Applying modifier {m}')
        collection = collection.map(m)
        #print('new coll size:',collection.size().getInfo())

    if filters_after:
        collection = collection.filter( filters_after )
        #print('final coll size:',collection.size().getInfo())

    return collection

    Queries for Google Earth Engine (GEE) images based off of the input values. See below for details.
    Outputs a GEE ImageCollection object.

    The following arguments are required--

    "ee_dir": The GEE directory you want to pull images from. For example, to get Sentinel-2 L2A images,
              input "COPERNICUS/S2_SR".

    "ee_roi": A GEE Geometry Polygon object specifying the bounds of the image query.

    "start_date": A string containing the first date of the date range you want your images to be from;
                  e.g., "2020-10-30".

    "end_date": A string containing the last date of the date range you want your images to be from.

    The following arguments are optional--

    "filters_before": A list of ee.Filter objects you want to apply to the ImageCollection *before* the modifiers
                      are applied. Default is None.
    
    "modifiers": A list of functions to map onto the ImageCollection using GEE's ".map()" method. Each function
                 must have as its input and output only a single GEE Image object. All functions will be applied
                 to all the Images in the ImageCollection. Defaults to an empty list.

    "filters_after": A list of ee.Filter objects you want to apply to the ImageCollection *after* the modifiers
                     are applied. Default is None.
    
Queries for Google Earth Engine (GEE) images based off of the input values. See below for details.
Outputs a GEE ImageCollection object.

The following arguments are required

"ee_dir": The GEE directory you want to pull images from. For example, to get Sentinel-2 L2A images,
input "COPERNICUS/S2_SR".

"ee_roi": A GEE Geometry Polygon object specifying the bounds of the image query.

"start_date": A string containing the first date of the date range you want your images to be from;
e.g., "2020-10-30".

"end_date": A string containing the last date of the date range you want your images to be from.

The following arguments are optional

"filters_before": A list of ee.Filter objects you want to apply to the ImageCollection *before* the modifiers
are applied. Default is None.

"modifiers": A list of functions to map onto the ImageCollection using GEE's ".map()" method. Each function
must have as its input and output only a single GEE Image object. All functions will be applied
to all the Images in the ImageCollection. Defaults to an empty list.

"filters_after": A list of ee.Filter objects you want to apply to the ImageCollection *after* the modifiers
are applied. Default is None.
Queries for Google Earth Engine ( GEE ) images based off of the input values . See below for details . Outputs a GEE ImageCollection object . The following arguments are required " ee_dir " : The GEE directory you want to pull images from . For example to get Sentinel - 2 L2A images input " COPERNICUS / S2_SR " . " ee_roi " : A GEE Geometry Polygon object specifying the bounds of the image query . " start_date " : A string containing the first date of the date range you want your images to be from ; e . g . " 2020 - 10 - 30 " . " end_date " : A string containing the last date of the date range you want your images to be from . The following arguments are optional " filters_before " : A list of ee . Filter objects you want to apply to the ImageCollection * before * the modifiers are applied . Default is None . " modifiers " : A list of functions to map onto the ImageCollection using GEE ' s " . map () " method . Each function must have as its input and output only a single GEE Image object . All functions will be applied to all the Images in the ImageCollection . Defaults to an empty list . " filters_after " : A list of ee . Filter objects you want to apply to the ImageCollection * after * the modifiers are applied . Default is None .
def makeImageCollection(ee_dir, ee_roi, start_date, end_date, filters_before=None, modifiers=[], filters_after=None):
    collection = ee.ImageCollection(ee_dir) \
                .filterDate(ee.Date(start_date), ee.Date(end_date)) \
                .filterBounds(ee_roi) \
                .map( lambda x: clipToROI(x, ee.Geometry(ee_roi)) )
    if filters_before is not None:
        collection = collection.filter( filters_before )
    for m in modifiers:
        collection = collection.map(m)
    if filters_after:
        collection = collection.filter( filters_after )
    return collection
def makeImageCollection ( ee_dir , ee_roi , start_date , end_date , filters_before = None , modifiers = [ ] , filters_after = None ) : collection = ee . ImageCollection ( ee_dir ) . filterDate ( ee . Date ( start_date ) , ee . Date ( end_date ) ) . filterBounds ( ee_roi ) . map ( lambda x : clipToROI ( x , ee . Geometry ( ee_roi ) ) ) if filters_before is not None : collection = collection . filter ( filters_before ) for m in modifiers : collection = collection . map ( m ) if filters_after : collection = collection . filter ( filters_after ) return collection
Queries for Google Earth Engine (GEE) images based off of the input values.
Queries for Google Earth Engine ( GEE ) images based off of the input values .
'''
    Queries for Google Earth Engine (GEE) images based off of the input values. See below for details.
    Outputs a GEE ImageCollection object.

    The following arguments are required--

    "ee_dir": The GEE directory you want to pull images from. For example, to get Sentinel-2 L2A images,
              input "COPERNICUS/S2_SR".

    "ee_roi": A GEE Geometry Polygon object specifying the bounds of the image query.

    "start_date": A string containing the first date of the date range you want your images to be from;
                  e.g., "2020-10-30".

    "end_date": A string containing the last date of the date range you want your images to be from.

    The following arguments are optional--

    "filters_before": A list of ee.Filter objects you want to apply to the ImageCollection *before* the modifiers
                      are applied. Default is None.
    
    "modifiers": A list of functions to map onto the ImageCollection using GEE's ".map()" method. Each function
                 must have as its input and output only a single GEE Image object. All functions will be applied
                 to all the Images in the ImageCollection. Defaults to an empty list.

    "filters_after": A list of ee.Filter objects you want to apply to the ImageCollection *after* the modifiers
                     are applied. Default is None.
    ''' ## Split into the original call/filters and the mapping #print(modifiers) #print("size of collection:",collection.size().getInfo()) #print(f'Applying modifier {m}') #print('new coll size:',collection.size().getInfo()) #print('final coll size:',collection.size().getInfo())
ee_dir
ee_roi
start_date
end_date
filters_before
modifiers
filters_after