def landsat(self, report_id, id): r = Report.get(Key(report_id)) z, x, y = Cell.cell_id(id) cell = Cell.get_or_default(r, x, y, z) bounds = cell.bounds(amazon_bounds) bounds = "%f,%f,%f,%f" % (bounds[1][1], bounds[1][0], bounds[0][1], bounds[0][0]) ee = EELandsat() d = ee.list(bounds=bounds) data = {} if len(d) >= 1: x = d[-1] img_info = x.split('/')[2][3:] path = img_info[:3] row = img_info[3:6] year = int(img_info[6:10]) julian_date = img_info[10:13] date = date_from_julian(int(julian_date), year) data = { 'info': img_info, 'path': path, 'row': row, 'year': year, 'timestamp': timestamp(date), 'date': date.isoformat() } return Response(json.dumps(data), mimetype='application/json')
def default_maps(): maps = [] r = Report.current() logging.info("report " + unicode(r)) landsat = EELandsat() ndfi = NDFI(past_month_range(r.start), r.range()) d = landsat.mapid(timestamp(r.start), datetime.datetime.now()) maps.append({'data': d, 'info': 'LANDSAT/LE7_L1T'}) #d = ndfi.mapid2() #if d: maps.append({'data' :d, 'info': 'ndfi difference'}) d = ndfi.smaid() if d: maps.append({'data': d, 'info': 'SMA'}) d = ndfi.rgb1id() if d: maps.append({'data': d, 'info': 'RGB'}) d = ndfi.ndfi0id() if d: maps.append({'data': d, 'info': 'NDFI T0'}) d = ndfi.ndfi1id() if d: maps.append({'data': d, 'info': 'NDFI T1'}) d = ndfi.baseline(r.base_map()) if d: maps.append({'data': d, 'info': 'Baseline'}) d = ndfi.rgb0id() if d: maps.append({'data': d, 'info': 'Previous RGB'}) return maps