Skip to content

Commit

Permalink
Adding new visualization layers : Baseline and Previous RGB
Browse files Browse the repository at this point in the history
  • Loading branch information
davethau committed Nov 1, 2012
1 parent f56c62c commit 54a4917
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/app.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
application: imazon-prototype
version: v03
application: sad-ee
version: v01
runtime: python
api_version: 1

Expand Down
41 changes: 28 additions & 13 deletions src/application/ee.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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'])
Expand Down Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions src/application/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 6 additions & 0 deletions src/application/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion src/static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<arraylayer.length;num++){
var lay = map_name.layers.get_by_name(arraylayer[num]);
Expand Down
1 change: 1 addition & 0 deletions src/static/js/models/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ var RGBStrechLayer = LayerModel.extend({

//parses token and mapid response from server and creates tile url
parse: function(data) {
//var base_url = 'https://earthengine.sandbox.google.com/map/{mapid}/{Z}/{X}/{Y}?token={token}';
var base_url = 'https://earthengine.googleapis.com/map/{mapid}/{Z}/{X}/{Y}?token={token}';
var url = base_url.replace('{mapid}', data.mapid).replace('{token}', data.token);
return {'url_pattern': url };
Expand Down

0 comments on commit 54a4917

Please # to comment.