scripts/download_sen12.py
def mergeCollection(self, imgC, test_coll=False):
        '''
        Uses Cloudfree Merging to merge a GEE ImageCollection into a single cloud-free image.

        "imgC": The ImageCollection you want to merge

        "test_coll": Boolean that determines whether or not to test the collection to see if it has a
        sufficient number of quality images. Used for Dynamic Date Range. Defaults to False.
        '''

    # Select the best images, which are below the cloud free threshold, sort them in reverse order (worst on top) for mosaicing
        ## same as the JS version
        # logging.info(f'---POLYGON {polygon_id}---')
        # logging.info(f'{date_range["start_date"]} to {date_range["end_date"]}')
        # logging.info(f'Collection size: {imgC.size().getInfo()}')

        filterBy='NON_QUALITY_PIXEL_PERCENTAGE'
        secondary_sort='CLOUDY_PIXEL_PERCENTAGE' 

        best = imgC.filterMetadata(filterBy, operator='less_than', value=self.qual_img_thresh)
        
        if test_coll:
            coll_is_good = collection_greater_than(best, self.qual_img_amount)

            # print('Coll is good:', coll_is_good)

            if not coll_is_good:
                return None
        
        # best_sorted = image_collection_secondary_sort(best,primary_sort=filterBy,secondary_sort=secondary_sort)
        best_sorted = best.sort(secondary_sort, False).sort(filterBy, False)

        # logging.info(f'Best size: {best.size().getInfo()}')

        # best_filtered = best.filterMetadata('NODATA_PIXEL_PERCENTAGE', 'less_than', 10)

        # logging.info(f'Filtered best size: {best_filtered.size().getInfo()}')
        # logging.info('')
        # logging.info('')

    #     return collection_quality_test_filter(imgC, best)
    #     print('Info on first image of collection:', imgC.first().getInfo())
        filtered = imgC.qualityMosaic(qualityBand='cloudShadowScore')

        # Add the quality mosaic to fill in any missing areas of the ROI which aren't covered by good images
        newC = ee.ImageCollection.fromImages( [filtered, best_sorted.mosaic()] )
        
    #     print("collection merged")

        return ee.Image(newC.mosaic())

        Uses Cloudfree Merging to merge a GEE ImageCollection into a single cloud-free image.

        "imgC": The ImageCollection you want to merge

        "test_coll": Boolean that determines whether or not to test the collection to see if it has a
        sufficient number of quality images. Used for Dynamic Date Range. Defaults to False.
        
Uses Cloudfree Merging to merge a GEE ImageCollection into a single cloud-free image.
"imgC": The ImageCollection you want to merge

"test_coll": Boolean that determines whether or not to test the collection to see if it has a
sufficient number of quality images. Used for Dynamic Date Range. Defaults to False.
Uses Cloudfree Merging to merge a GEE ImageCollection into a single cloud - free image . " imgC " : The ImageCollection you want to merge " test_coll " : Boolean that determines whether or not to test the collection to see if it has a sufficient number of quality images . Used for Dynamic Date Range . Defaults to False .
def mergeCollection(self, imgC, test_coll=False):
        filterBy='NON_QUALITY_PIXEL_PERCENTAGE'
        secondary_sort='CLOUDY_PIXEL_PERCENTAGE' 
        best = imgC.filterMetadata(filterBy, operator='less_than', value=self.qual_img_thresh)
        if test_coll:
            coll_is_good = collection_greater_than(best, self.qual_img_amount)
            if not coll_is_good:
                return None
        best_sorted = best.sort(secondary_sort, False).sort(filterBy, False)
        filtered = imgC.qualityMosaic(qualityBand='cloudShadowScore')
        newC = ee.ImageCollection.fromImages( [filtered, best_sorted.mosaic()] )
        return ee.Image(newC.mosaic())
def mergeCollection ( self , imgC , test_coll = False ) : filterBy = 'NON_QUALITY_PIXEL_PERCENTAGE' secondary_sort = 'CLOUDY_PIXEL_PERCENTAGE' best = imgC . filterMetadata ( filterBy , operator = 'less_than' , value = self . qual_img_thresh ) if test_coll : coll_is_good = collection_greater_than ( best , self . qual_img_amount ) if not coll_is_good : return None best_sorted = best . sort ( secondary_sort , False ) . sort ( filterBy , False ) filtered = imgC . qualityMosaic ( qualityBand = 'cloudShadowScore' ) newC = ee . ImageCollection . fromImages ( [ filtered , best_sorted . mosaic ( ) ] ) return ee . Image ( newC . mosaic ( ) )
Uses Cloudfree Merging to merge a GEE ImageCollection into a single cloud-free image.
Uses Cloudfree Merging to merge a GEE ImageCollection into a single cloud - free image .
'''
        Uses Cloudfree Merging to merge a GEE ImageCollection into a single cloud-free image.

        "imgC": The ImageCollection you want to merge

        "test_coll": Boolean that determines whether or not to test the collection to see if it has a
        sufficient number of quality images. Used for Dynamic Date Range. Defaults to False.
        ''' # Select the best images, which are below the cloud free threshold, sort them in reverse order (worst on top) for mosaicing ## same as the JS version # logging.info(f'---POLYGON {polygon_id}---') # logging.info(f'{date_range["start_date"]} to {date_range["end_date"]}') # logging.info(f'Collection size: {imgC.size().getInfo()}') # print('Coll is good:', coll_is_good) # best_sorted = image_collection_secondary_sort(best,primary_sort=filterBy,secondary_sort=secondary_sort) # logging.info(f'Best size: {best.size().getInfo()}') # best_filtered = best.filterMetadata('NODATA_PIXEL_PERCENTAGE', 'less_than', 10) # logging.info(f'Filtered best size: {best_filtered.size().getInfo()}') # logging.info('') # logging.info('') #     return collection_quality_test_filter(imgC, best) #     print('Info on first image of collection:', imgC.first().getInfo()) # Add the quality mosaic to fill in any missing areas of the ROI which aren't covered by good images #     print("collection merged")
self
imgC
test_coll