def _executeWdpa(args): """Query GEE using supplied WDPA id.""" action, data = CartoDbExecutor.execute(args, BiomasLossSql) if action == 'error': return action, data rows = data['rows'] data.pop('rows') data.pop('download_urls') if rows[0]['geojson'] == None: args['geojson'] = rows[0]['geojson'] args['begin'] = args['begin'] if 'begin' in args else '2001-01-01' args['end'] = args['end'] if 'end' in args else '2013-01-01' data['params'].pop('geojson') data['gain'] = None data['loss'] = None data['tree-extent'] = None data['biomass'] = None data['biomass_loss'] = None data['biomass_loss_by_year'] = None data['c_loss_by_year'] = None data['co2_loss_by_year'] = None elif rows: args['geojson'] = rows[0]['geojson'] args['begin'] = args['begin'] if 'begin' in args else '2001-01-01' args['end'] = args['end'] if 'end' in args else '2013-01-01' action, data = _execute_geojson(args) data['params'].pop('geojson') return action, data
def _executeWdpa(args): """Query GEE using supplied WDPA id.""" action, data = CartoDbExecutor.execute(args, BiomasLossSql) if action == 'error': return action, data rows = data['rows'] data.pop('rows') data.pop('download_urls') if rows[0]['geojson']==None: args['geojson'] = rows[0]['geojson'] args['begin'] = args['begin'] if 'begin' in args else '2001-01-01' args['end'] = args['end'] if 'end' in args else '2013-01-01' data['params'].pop('geojson') data['gain'] = None data['loss'] = None data['tree-extent'] = None data['biomass'] = None data['biomass_loss'] = None data['biomass_loss_by_year'] = None data['c_loss_by_year'] = None data['co2_loss_by_year'] = None elif rows: args['geojson'] = rows[0]['geojson'] args['begin'] = args['begin'] if 'begin' in args else '2001-01-01' args['end'] = args['end'] if 'end' in args else '2013-01-01' action, data = _execute_geojson(args) data['params'].pop('geojson') return action, data
def getAlertCount(args): begin = args.get('begin') end = args.get('end') if 'geojson' not in args: action, data = CartoDbExecutor.execute(args, GeometrySql) args['geojson'] = data['rows'][0]['geojson'] confirmed_only = False if 'glad_confirmed_only' in args: confirmed_only = True rasters = rastersForPeriod(begin, end, confirmed_only) try: esri_json = geojsonToEsriJson(args.get('geojson')) alert_count = alertCount(begin, end, getHistogram(rasters, esri_json, confirmed_only)) return 'respond', decorateWithArgs({ "min_date": begin.isoformat(), "max_date": end.isoformat(), "value": alert_count, "notes": request_notes }, args) except HistogramError as e: return 'error', decorateWithArgs(e.value, args) except DeadlineExceededError as e: return 'error', decorateWithArgs({ "error": { "code": 408, "message": "Request timed out" }}, args)
def getAlertCount(args): begin = args.get('begin') end = args.get('end') if 'geojson' not in args: action, data = CartoDbExecutor.execute(args, GeometrySql) args['geojson'] = data['rows'][0]['geojson'] confirmed_only = False if 'glad_confirmed_only' in args: confirmed_only = True rasters = rastersForPeriod(begin, end, confirmed_only) try: esri_json = geojsonToEsriJson(args.get('geojson')) alert_count = alertCount( begin, end, getHistogram(rasters, esri_json, confirmed_only)) return 'respond', decorateWithArgs( { "min_date": begin.isoformat(), "max_date": end.isoformat(), "value": alert_count, "notes": request_notes }, args) except HistogramError as e: return 'error', decorateWithArgs(e.value, args) except DeadlineExceededError as e: return 'error', decorateWithArgs( {"error": { "code": 408, "message": "Request timed out" }}, args)
def _executeIflId1(args): """Query subnational by iso code and GADM id.""" action, data = CartoDbExecutor.execute(args, BiomasLossSql) if action == 'error': return action, data rows = data['rows'] data.pop('rows') data.pop('download_urls') data['years'] = rows return action, data
def execute(args): if 'begin' in args: args['begin'] = args['begin'].strftime('%Y-%m-%d') if 'end' in args: args['end'] = args['end'].strftime('%Y-%m-%d') action, data = CartoDbExecutor.execute(args, QuiccSql) if action == 'redirect' or action == 'error': return action, data return _processResults(action, data)
def execute(args): if 'begin' in args: args['begin'] = args['begin'].strftime('%Y-%m-%d') if 'end' in args: args['end'] = args['end'].strftime('%Y-%m-%d') action, data = CartoDbExecutor.execute(args, FiresSql) if action == 'redirect' or action == 'error': return action, data return _processResults(action, data)
def _executeIfl(args): """Query national by iso code.""" action, data = CartoDbExecutor.execute(args, UmdSql) if action == 'error': return action, data rows = data['rows'] data.pop('rows') data.pop('download_urls') data['years'] = rows return action, data
def _executeIfl(args): """Query national by iso code.""" action, data = CartoDbExecutor.execute(args, BiomasLossSql) if action == 'error': return action, data rows = data['rows'] data.pop('rows') data.pop('download_urls') data['years'] = rows return action, data
def _executeIflId1(args): """Query subnational by iso code and GADM id.""" action, data = CartoDbExecutor.execute(args, UmdSql) if action == 'error': return action, data rows = data['rows'] data.pop('rows') data.pop('download_urls') data['years'] = rows return action, data
def _executeIfl(args): """Query national by iso code.""" action, data = CartoDbExecutor.execute(args, UmdSql) if action == 'error' or data.get('rows', 'empty')=='empty': return action, data rows = data['rows'] data.pop('rows') data.pop('download_urls') data['years'] = rows return action, data
def execute(args): #TODO: Document what can go in 'args'. args['version'] = 'v1' if 'begin' in args: args['begin'] = args['begin'].strftime('%Y-%m-%d') if 'end' in args: args['end'] = args['end'].strftime('%Y-%m-%d') action, data = CartoDbExecutor.execute(args, FormaSql) #To get the count: data.get('rows')[0].get('value') if action == 'redirect' or action == 'error': return action, data return _processResults(action, data)
def _executeUse(args): """Query GEE using supplied concession id.""" action, data = CartoDbExecutor.execute(args, UmdSql) if action == 'error': return action, data rows = data['rows'] data.pop('rows') data.pop('download_urls') if rows: args['geojson'] = rows[0]['geojson'] args['begin'] = args['begin'] if 'begin' in args else '2001-01-01' args['end'] = args['end'] if 'end' in args else '2013-01-01' action, data = _execute_geojson(args) data['params'].pop('geojson') return action, data
def _executeUse(args): """Query GEE using supplied concession id.""" action, data = CartoDbExecutor.execute(args, BiomasLossSql) if action == 'error': return action, data rows = data['rows'] data.pop('rows') data.pop('download_urls') if rows: args['geojson'] = rows[0]['geojson'] args['begin'] = args['begin'] if 'begin' in args else '2001-01-01' args['end'] = args['end'] if 'end' in args else '2013-01-01' action, data = _execute_geojson(args) data['params'].pop('geojson') return action, data
def _executeId1(args): """Query subnational by iso code and GADM id.""" action, data = CartoDbExecutor.execute(args, BiomasLossSql) if action == 'error': return action, data begin = args.get('begin').split('-')[0] end = args.get('end').split('-')[0] rows = data['rows'] data.pop('rows') data.pop('download_urls') data['tree_loss_by_year'] = _indicator_selector(rows, 1, begin, end) data['biomass_loss_by_year'] = _indicator_selector(rows, 12, begin, end) data['c_loss_by_year'] = _indicator_selector(rows, 13, begin, end) data['co2_loss_by_year'] = _indicator_selector(rows, 14, begin, end) data['biomass'] = _indicator_selector(rows, 4, begin, end) data['biomass_loss'] = _sum_range(data['biomass_loss_by_year'], begin, end) return action, data
def execute(args): args['version'] = 'v1' action, data = CartoDbExecutor.execute(args, FormaSql) if action == 'redirect' or action == 'error': return action, data return _processResults(action, data)
def execute(args): args['version'] = 'v2' action, data = CartoDbExecutor.execute(args, TerraiSql) if action == 'redirect' or action == 'error': return action, data return _processResults(action, data)
def bbox(args): action, bboxResponse = CartoDbExecutor.execute(args, BoundingSql) return extent(json.loads(bboxResponse['rows'][0]['bbox']))
def execute(args): action, data = CartoDbExecutor.execute(args, ImazonSql) if action == 'redirect' or action == 'error': return action, data return _processResults(action, data, args)
def execute(args): action, data = CartoDbExecutor.execute(args, QuiccSql) if action == 'redirect' or action == 'error': return action, data return _processResults(action, data)