diff --git a/src/app.yaml b/src/app.yaml index 9def01f..06a7e42 100644 --- a/src/app.yaml +++ b/src/app.yaml @@ -1,5 +1,5 @@ -application: imazon-prototype -version: v03 +application: sad-ee +version: v01 runtime: python api_version: 1 diff --git a/src/application/ee.py b/src/application/ee.py index 9ec11c2..c57d2ba 100755 --- a/src/application/ee.py +++ b/src/application/ee.py @@ -15,6 +15,7 @@ METER2_TO_KM2 = 1.0/(1000*1000) CALL_SCOPE = "SAD" +#CALL_SCOPE = "sad_test" KRIGING = "kriging/com.google.earthengine.examples.kriging.KrigedModisImage" class Stats(object): @@ -369,8 +370,17 @@ def ndfi0id(self): params = self._NDFI_period_image_command(self.last_period, 1) return self._execute_cmd('/mapid', params) - def baseline(self): - params = self._baseline_image_command() + def baseline(self, asset_id): + params = self._baseline_image_command(asset_id) + return self._execute_cmd('/mapid', params) + + def rgb0id(self): + + quarter_msec = 1000 * 60 * 60 * 24 * 90 + last_start = self.last_period['start'] + last_period = dict(start=last_start - quarter_msec, + end=self.last_period['end']) + params = self._RGB_image_command(last_period) return self._execute_cmd('/mapid', params) def ndfi1id(self): @@ -470,11 +480,19 @@ def _image_composition(self, image_list): }); return specs; - def _baseline_image(self): - return { - 'creator': CALL_SCOPE + '/com.google.earthengine.examples.sad.ProdesImage', - 'args': ["Xy539pUtkRlazIO1"] - } + def _baseline_image(self, asset_id): + + classification = {"algorithm":"Image.select", + "input":{"type":"Image", "id":asset_id}, + "bandSelectors":["classification"]} + + mask = {"algorithm":"Image.eq", + "image1":classification, + "image2":{"algorithm":"Constant","value":4}} + + image = {"algorithm":"Image.mask", "image":classification, "mask":mask} + return image + def _krig_filter(self, period): work_month = self.getMidMonth(period['start'], period['end']) @@ -546,13 +564,10 @@ def _NDFI_period_image_command(self, period, long_span=0): "gamma": 1.6 } - def _baseline_image_command(self): - baseline_image = self._baseline_image() + def _baseline_image_command(self, asset_id): + baseline_image = self._baseline_image(asset_id) return { - "image": json.dumps(baseline_image), - "bands": 'classification', - "min": 0, - "max": 9 + "image": json.dumps(baseline_image) } def _RGB_image_command(self, period): diff --git a/src/application/settings.py b/src/application/settings.py index 2326e60..de85329 100755 --- a/src/application/settings.py +++ b/src/application/settings.py @@ -26,6 +26,7 @@ FT_TABLE = 'imazon_testing.csv' FT_TABLE_ID = '2676501' EE_API = 'https://earthengine.googleapis.com' + #EE_API = 'https://earthengine.sandbox.google.com' EE_TILE_SERVER = EE_API + '/map/' else: EE_API = 'https://earthengine.googleapis.com' diff --git a/src/application/views.py b/src/application/views.py index 8e3c87f..558ef8f 100755 --- a/src/application/views.py +++ b/src/application/views.py @@ -56,6 +56,12 @@ def default_maps(): d = ndfi.ndfi1id() if 'data' in d: maps.append({'data' :d['data'], 'info': 'NDFI T1'}) + d = ndfi.baseline(r.base_map()) + if 'data' in d: + maps.append({'data' :d['data'], 'info': 'Baseline'}) + d = ndfi.rgb0id() + if 'data' in d: + maps.append({'data' :d['data'], 'info': 'Previous RGB'}) return maps def get_or_create_user(): diff --git a/src/static/js/app.js b/src/static/js/app.js index 7a90bda..f4f3da4 100755 --- a/src/static/js/app.js +++ b/src/static/js/app.js @@ -371,7 +371,7 @@ $(function() { */ var arraylayer = new Array("Brazil Legal Amazon","Brazil Municipalities Public","Brazil States Public","Brazil Federal Conservation Unit Public", "Brazil State Conservation Unit Public","LANDSAT/L7_L1T","SMA","RGB","NDFI T0","NDFI T1","NDFI analysis","True color RGB141","False color RGB421", - "F color infrared RGB214","Validated polygons"); + "F color infrared RGB214", "Baseline", "Previous RGB", "Validated polygons"); var save_status_layer=""; for(var num=0; num