예제 #1
0
파일: main.py 프로젝트: acocac/CNN-tests
def ee_pre_processing(request):
    request = request.get_json()

    # Variables
    collection = request.get('collection')
    startDate = ee.Date(request.get('start'))
    stopDate  = ee.Date(request.get('end'))
    scale  = request.get('scale')
    # Bands
    bands = ee_collection_specifics.ee_bands(collection)

    # Get composite
    image = ee_collection_specifics.Composite(collection)(startDate, stopDate)
    image = image.select(bands)

    # Normalize images
    if ee_collection_specifics.normalize(collection):
        # Get min man values for each band
        values = min_max_values(image, collection, scale)

        # Normalize images
        image = normalize_ee_images(image, collection, values)
    else:
        values = {}
        
    return json.dumps({'bands_min_max': values, 'composite': image.serialize()})
예제 #2
0
파일: utils.py 프로젝트: acocac/CNN-tests
def normalize_ee_images(image, collection, values):

    Bands = ee_collection_specifics.ee_bands(collection)

    # Normalize [0, 1] ee images
    for i, band in enumerate(Bands):
        if i == 0:
            image_new = image.select(band).clamp(values[band+'_min'], values[band+'_max'])\
                                .subtract(values[band+'_min'])\
                                .divide(values[band+'_max']-values[band+'_min'])
        else:
            image_new = image_new.addBands(image.select(band).clamp(values[band+'_min'], values[band+'_max'])\
                                    .subtract(values[band+'_min'])\
                                    .divide(values[band+'_max']-values[band+'_min']))

    return image_new
예제 #3
0
    def __init__(self, point, buffer, startDate, stopDate, scale, collection):
        """
        Class used to get the datasets from Earth Engine
        Parameters
        ----------
        point : list
            A list of two [x,y] coordinates with the center of the area of interest.
        buffer : number
            Buffer in meters
        startDate : string
        stopDate : string
        scale: number
            Pixel size in meters.
        collection: string
            Name of each collection.

        """
        
        self.point = point
        self.buffer = buffer
        self.startDate = startDate
        self.stopDate = stopDate       
        self.scale = scale 
        self.collection = collection
        
        # Area of Interest
        self.geom = ee.Geometry.Point(self.point).buffer(self.buffer)
        self.region = self.geom.bounds()
        
        # Image Collection
        self.image_collection = ee_collection_specifics.ee_collections(self.collection)
 
        # Bands
        self.bands = ee_collection_specifics.ee_bands(self.collection)
    
        # normalized Difference bands and their names
        self.normDiff_bands = ee_collection_specifics.normDiff_bands(self.collection)
        self.normDiff_bands_names = ee_collection_specifics.normDiff_bands_names(self.collection)