scripts/download_sen12.py
def export_single_feature(self):
        '''
        Based off of the current polygon and its date range, queries for images, merges them, and exports
        the resulting cloud-free image.

        The following functions are applied to each image in the query:
            inject_B10: If the images are from Sentinel-2 L2A, they lack the 'B10' band; this function finds the matching
                        L1C image and gets its B10 band.
            sentinel2CloudScore: Makes a cloud mask
            calcCloudCoverage: Calculates the cloud coverage of the image based off of the cloud mask
            sentinel2ProjectShadows: Makes a mask of cloud shadows
            computeQualityScore: Computes the Quality Pixel Percentage score for the image
        '''
        modifiers = []
        if self.sensor['name'].lower() == "copernicus/s2_sr":
            #print('Inject B10')
            modifiers.append(inject_B10)
        modifiers += [sentinel2CloudScore, calcCloudCoverage, sentinel2ProjectShadows, computeQualityScore]

        ee_dir = self.sensor['name']
        roi_ee = ee.Geometry.Polygon(self.current_poly['roi'])
        start_date = self.current_poly['date_range']['start_date']
        end_date = self.current_poly['date_range']['end_date']
        filters_before, filters_after = self._makeFilterList()

        imgC = makeImageCollection(ee_dir, roi_ee, start_date, end_date, filters_before, modifiers, filters_after)

        #print(f'Size of polygon {polygon_id}: {imgC.size().getInfo()}')
        # print(imgC.size().getInfo())
        # return None
        ## sort was not in the original version
        #image_collection = image_collection.sort(sort_by)
        ## below line was in the original verson;
        ## changing to the JS version
        ## img = image_collection.mosaic().clip(roi_ee)



        # finds final offset 
        max_offset = self.offset_dict[max(self.offset_dict.keys())]

        if self.skip_test_check is True or (self.current_poly['date_range']['day_offset'] == max_offset):
            cloudFree = self.mergeCollection(imgC, test_coll=False)
        else:
            cloudFree = self.mergeCollection(imgC, test_coll=True)

        if cloudFree is None:
            self.current_poly['date_range'] = self._expand_date_range()
            return self.export_single_feature()

        else:
            cloudFree = cloudFree.clip(roi_ee).reproject('EPSG:4326', None, 10)

            ## make NDVI band
            cloudFree = self._add_ndvi_band(img=cloudFree)


            self.export_params['img'] = cloudFree
            self.export_params['roi'] = self.current_poly['roi']
            self.export_params['sensor_name'] = self.sensor['name'].lower()
            self.export_params['bands'] = self.sensor['bands']

            return self.exportImageToGCS()

        Based off of the current polygon and its date range, queries for images, merges them, and exports
        the resulting cloud-free image.

        The following functions are applied to each image in the query:
            inject_B10: If the images are from Sentinel-2 L2A, they lack the 'B10' band; this function finds the matching
                        L1C image and gets its B10 band.
            sentinel2CloudScore: Makes a cloud mask
            calcCloudCoverage: Calculates the cloud coverage of the image based off of the cloud mask
            sentinel2ProjectShadows: Makes a mask of cloud shadows
            computeQualityScore: Computes the Quality Pixel Percentage score for the image
        
Based off of the current polygon and its date range, queries for images, merges them, and exports
the resulting cloud-free image.

The following functions are applied to each image in the query:
inject_B10: If the images are from Sentinel-2 L2A, they lack the 'B10' band; this function finds the matching
L1C image and gets its B10 band.
sentinel2CloudScore: Makes a cloud mask
calcCloudCoverage: Calculates the cloud coverage of the image based off of the cloud mask
sentinel2ProjectShadows: Makes a mask of cloud shadows
computeQualityScore: Computes the Quality Pixel Percentage score for the image
Based off of the current polygon and its date range queries for images merges them and exports the resulting cloud - free image . The following functions are applied to each image in the query : inject_B10 : If the images are from Sentinel - 2 L2A they lack the ' B10 ' band ; this function finds the matching L1C image and gets its B10 band . sentinel2CloudScore : Makes a cloud mask calcCloudCoverage : Calculates the cloud coverage of the image based off of the cloud mask sentinel2ProjectShadows : Makes a mask of cloud shadows computeQualityScore : Computes the Quality Pixel Percentage score for the image
def export_single_feature(self):
        modifiers = []
        if self.sensor['name'].lower() == "copernicus/s2_sr":
            modifiers.append(inject_B10)
        modifiers += [sentinel2CloudScore, calcCloudCoverage, sentinel2ProjectShadows, computeQualityScore]
        ee_dir = self.sensor['name']
        roi_ee = ee.Geometry.Polygon(self.current_poly['roi'])
        start_date = self.current_poly['date_range']['start_date']
        end_date = self.current_poly['date_range']['end_date']
        filters_before, filters_after = self._makeFilterList()
        imgC = makeImageCollection(ee_dir, roi_ee, start_date, end_date, filters_before, modifiers, filters_after)
        max_offset = self.offset_dict[max(self.offset_dict.keys())]
        if self.skip_test_check is True or (self.current_poly['date_range']['day_offset'] == max_offset):
            cloudFree = self.mergeCollection(imgC, test_coll=False)
        else:
            cloudFree = self.mergeCollection(imgC, test_coll=True)
        if cloudFree is None:
            self.current_poly['date_range'] = self._expand_date_range()
            return self.export_single_feature()
        else:
            cloudFree = cloudFree.clip(roi_ee).reproject('EPSG:4326', None, 10)
            cloudFree = self._add_ndvi_band(img=cloudFree)
            self.export_params['img'] = cloudFree
            self.export_params['roi'] = self.current_poly['roi']
            self.export_params['sensor_name'] = self.sensor['name'].lower()
            self.export_params['bands'] = self.sensor['bands']
            return self.exportImageToGCS()
def export_single_feature ( self ) : modifiers = [ ] if self . sensor [ 'name' ] . lower ( ) == "copernicus/s2_sr" : modifiers . append ( inject_B10 ) modifiers += [ sentinel2CloudScore , calcCloudCoverage , sentinel2ProjectShadows , computeQualityScore ] ee_dir = self . sensor [ 'name' ] roi_ee = ee . Geometry . Polygon ( self . current_poly [ 'roi' ] ) start_date = self . current_poly [ 'date_range' ] [ 'start_date' ] end_date = self . current_poly [ 'date_range' ] [ 'end_date' ] filters_before , filters_after = self . _makeFilterList ( ) imgC = makeImageCollection ( ee_dir , roi_ee , start_date , end_date , filters_before , modifiers , filters_after ) max_offset = self . offset_dict [ max ( self . offset_dict . keys ( ) ) ] if self . skip_test_check is True or ( self . current_poly [ 'date_range' ] [ 'day_offset' ] == max_offset ) : cloudFree = self . mergeCollection ( imgC , test_coll = False ) else : cloudFree = self . mergeCollection ( imgC , test_coll = True ) if cloudFree is None : self . current_poly [ 'date_range' ] = self . _expand_date_range ( ) return self . export_single_feature ( ) else : cloudFree = cloudFree . clip ( roi_ee ) . reproject ( 'EPSG:4326' , None , 10 ) cloudFree = self . _add_ndvi_band ( img = cloudFree ) self . export_params [ 'img' ] = cloudFree self . export_params [ 'roi' ] = self . current_poly [ 'roi' ] self . export_params [ 'sensor_name' ] = self . sensor [ 'name' ] . lower ( ) self . export_params [ 'bands' ] = self . sensor [ 'bands' ] return self . exportImageToGCS ( )
Based off of the current polygon and its date range, queries for images, merges them, and exports
the resulting cloud-free image.
Based off of the current polygon and its date range queries for images merges them and exports the resulting cloud - free image .
'''
        Based off of the current polygon and its date range, queries for images, merges them, and exports
        the resulting cloud-free image.

        The following functions are applied to each image in the query:
            inject_B10: If the images are from Sentinel-2 L2A, they lack the 'B10' band; this function finds the matching
                        L1C image and gets its B10 band.
            sentinel2CloudScore: Makes a cloud mask
            calcCloudCoverage: Calculates the cloud coverage of the image based off of the cloud mask
            sentinel2ProjectShadows: Makes a mask of cloud shadows
            computeQualityScore: Computes the Quality Pixel Percentage score for the image
        ''' #print('Inject B10') #print(f'Size of polygon {polygon_id}: {imgC.size().getInfo()}') # print(imgC.size().getInfo()) # return None ## sort was not in the original version #image_collection = image_collection.sort(sort_by) ## below line was in the original verson; ## changing to the JS version ## img = image_collection.mosaic().clip(roi_ee) # finds final offset  ## make NDVI band
self