def __init__(self, geometry, startDate, stopDate, collection): """ Class used to get composites from Earth Engine Parameters ---------- geometry : GeoJSON GeoJSON with a polygon. startDate : string stopDate : string collection: string Name of a collection. """ self.geometry = geometry self.startDate = startDate self.stopDate = stopDate self.collection = collection self.scale = ee_collection_specifics.scales(self.collection) self.color = '#2BA4A0' self.style_function = lambda x: { 'fillOpacity': 0.0, 'weight': 4, 'color': self.color } # Earth Engine tile URL self.ee_tiles = 'https://earthengine.googleapis.com/map/{mapid}/{{z}}/{{x}}/{{y}}?token={token}' self.bucket = 'skydipper_materials' # Area of Interest self.region = self.geometry.get('features')[0].get('geometry').get( 'coordinates') self.polygon = ee.Geometry.Polygon(self.region) self.centroid = self.polygon.centroid().getInfo().get( 'coordinates')[::-1] self.locations = list( map(tuple, list(map(lambda x: x[::-1], self.region[0])))) self.bbox = self.polygon.bounds().getInfo().get('coordinates')[0] self.bounds = [self.bbox[0][::-1], self.bbox[2][::-1]] # Image Collection self.image_collection = ee_collection_specifics.ee_collections( self.collection) # Image Visualization parameters self.vis = ee_collection_specifics.ee_vis(self.collection) # Saving parameters self.visSave = { 'dimensions': 1024, 'format': 'png', 'crs': 'EPSG:3857', 'region': self.region }
def create_collection(self, scale=None): years = np.arange(self.start_year, self.stop_year + 1) dic = ee_collection_specifics.date_range(self.instrument) years_range = list(map(list, list(dic.values()))) collections = list(dic.keys()) image_list = [] for year in years: n = 0 in_range = False for sub_years in years_range: if year in sub_years: in_range = True break n = +1 if not in_range: raise ValueError(f'Year out of range.') collection = collections[n] if scale: scale = scale else: scale = ee_collection_specifics.scales(collection) # Image Collection image_collection = ee_collection_specifics.ee_collections( collection) # Image Visualization parameters vis = ee_collection_specifics.ee_vis(collection) step_range = ee_collection_specifics.step_range(collection) startDate = ee.Date(str(year + step_range[0]) + '-12-31') stopDate = ee.Date(str(year + step_range[1]) + '-12-31') image = ee_collection_specifics.Composite(collection)( image_collection, startDate, stopDate, scale, self.polygon) # convert image to an RGB visualization image_list.append(self.visFun(image, vis)) return image_list
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)
def __init__(self, point, buffer, startDate, stopDate, scale, path, 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.path = path self.collection = collection # Area of Interest self.geom = ee.Geometry.Point(self.point).buffer(self.buffer) self.region = self.geom.bounds().getInfo()['coordinates'] # Image Collection self.image_collection = ee_collection_specifics.ee_collections(self.collection) # Image Visualization parameters self.vis = ee_collection_specifics.ee_vis(self.collection) # Saving parameters self.visSave = {'dimensions': 1024, 'format': 'png', 'crs': 'EPSG:4326'}