def main(): a = AnalyticsEngine() e = ExecutionEngine() # Lake Burley Griffin dimensions = {'x': {'range': (149.07, 149.18)}, 'y': {'range': (-35.32, -35.28)}, 'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}} arrays = a.create_array(('LANDSAT_5', 'nbar'), ['nir', 'red'], dimensions, 'get_data') ndvi = a.apply_bandmath(arrays, '((array1 - array2) / (array1 + array2))', 'ndvi') e.execute_plan(a.plan) plot(e.cache['ndvi']) b30_result = e.cache['get_data']['array_result']['red'] b40_result = e.cache['get_data']['array_result']['nir'] ndvi_result = e.cache['ndvi']['array_result']['ndvi'] b30_data = Data(x=b30_result[:, ::-1, :], label='B30') b40_data = Data(x=b40_result[:, ::-1, :], label='B40') ndvi_data = Data(x=ndvi_result[:, ::-1, :], label='ndvi') long_data = Data(x=b40_result.coords['x'], label='long') lat_data = Data(x=b40_result.coords['y'], label='lat') time_data = Data(x=b40_result.coords['time'], label='time') collection = DataCollection([ndvi_data, b30_data, b40_data, long_data, lat_data, time_data, ]) app = GlueApplication(collection) app.start()
def main(): a = AnalyticsEngine() e = ExecutionEngine() # Lake Burley Griffin dimensions = {'x': {'range': (149.07, 149.18)}, 'y': {'range': (-35.32, -35.28)}, 'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}} b40 = a.create_array(('LANDSAT_5', 'nbar'), ['nir'], dimensions, 'b40') b30 = a.create_array(('LANDSAT_5', 'nbar'), ['red'], dimensions, 'b30') ndvi = a.apply_expression([b40, b30], '((array1 - array2) / (array1 + array2))', 'ndvi') e.execute_plan(a.plan) plot(e.cache['ndvi']) b30_result = e.cache['b30']['array_result']['red'] b40_result = e.cache['b40']['array_result']['nir'] ndvi_result = e.cache['ndvi']['array_result']['ndvi'] b30_data = Data(x=b30_result[:, ::-1, :], label='B30') b40_data = Data(x=b40_result[:, ::-1, :], label='B40') ndvi_data = Data(x=ndvi_result[:, ::-1, :], label='ndvi') long_data = Data(x=b40_result.coords['x'], label='long') lat_data = Data(x=b40_result.coords['y'], label='lat') time_data = Data(x=b40_result.coords['time'], label='time') collection = DataCollection([ndvi_data, b30_data, b40_data, long_data, lat_data, time_data, ]) app = GlueApplication(collection) app.start()
def main(): a = AnalyticsEngine() e = ExecutionEngine() # Lake Burley Griffin dimensions = {'x': {'range': (149.07, 149.18)}, 'y': {'range': (-35.32, -35.28)}, 'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}} ndvi = a.apply_sensor_specific_bandmath('LANDSAT_5', 'nbar', 'ndvi', dimensions, 'get_data', 'ndvi') result = e.execute_plan(a.plan) plot(e.cache['ndvi']) b30_result = e.cache['get_data']['array_result']['red'] b40_result = e.cache['get_data']['array_result']['nir'] ndvi_result = e.cache['ndvi']['array_result']['ndvi'] b30_data = Data(x=b30_result[:, ::-1, :], label='B30') b40_data = Data(x=b40_result[:, ::-1, :], label='B40') ndvi_data = Data(x=ndvi_result[:, ::-1, :], label='ndvi') long_data = Data(x=b40_result.coords['x'], label='long') lat_data = Data(x=b40_result.coords['y'], label='lat') time_data = Data(x=b40_result.coords['time'], label='time') collection = DataCollection([ndvi_data, b30_data, b40_data, long_data, lat_data, time_data, ]) app = GlueApplication(collection) app.start()
def main(): a = AnalyticsEngine() e = ExecutionEngine() # Lake Burley Griffin dimensions = { 'x': { 'range': (149.07, 149.18) }, 'y': { 'range': (-35.32, -35.28) }, 'time': { 'range': (datetime(1990, 1, 1), datetime(1990, 12, 31)) } } arrays = a.create_array(('LANDSAT_5', 'nbar'), ['nir'], dimensions, 'get_data') median_xy = a.apply_generic_reduction(arrays, ['y', 'x'], 'median(array1)', 'medianXY') result = e.execute_plan(a.plan) plot(e.cache['medianXY'])
def main(): a = AnalyticsEngine() e = ExecutionEngine() # Lake Burley Griffin dimensions = {'x': {'range': (149.07, 149.18)}, 'y': {'range': (-35.32, -35.28)}, 'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}} arrays = a.create_array(('LANDSAT_5', 'nbar'), ['nir'], dimensions, 'get_data') median_t = a.apply_generic_reduction(arrays, ['time'], 'median(array1)', 'medianT') result = e.execute_plan(a.plan) plot(e.cache['medianT']) b40_result = e.cache['get_data']['array_result']['nir'] median_result = e.cache['medianT']['array_result']['medianT'] b40_data = Data(x=b40_result[:, ::-1, :], label='B40') median_data = Data(x=median_result[::-1, :], label='medianT') long_data = Data(x=b40_result.coords['x'], label='long') lat_data = Data(x=b40_result.coords['y'], label='lat') time_data = Data(x=b40_result.coords['time'], label='time') collection = DataCollection([median_data, b40_data, long_data, lat_data, time_data, ]) app = GlueApplication(collection) app.start()
def main(): a = AnalyticsEngine() e = ExecutionEngine() # Lake Burley Griffin dimensions = {'x': {'range': (149.07, 149.18)}, 'y': {'range': (-35.32, -35.28)}, 'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}} arrays = a.create_array(('LANDSAT_5', 'nbar'), ['nir'], dimensions, 'get_data') median = a.apply_expression(arrays, 'median(array1, 1, 2)', 'medianXY') e.execute_plan(a.plan) plot(e.cache['medianXY'])
def main(): a = AnalyticsEngine() e = ExecutionEngine() # Lake Burley Griffin dimensions = { 'x': { 'range': (149.07, 149.18) }, 'y': { 'range': (-35.32, -35.28) }, 'time': { 'range': (datetime(1990, 1, 1), datetime(1990, 12, 31)) } } arrays = a.create_array(('LANDSAT_5', 'nbar'), ['nir'], dimensions, 'get_data') median_t = a.apply_generic_reduction(arrays, ['time'], 'median(array1)', 'medianT') result = e.execute_plan(a.plan) plot(e.cache['medianT']) b40_result = e.cache['get_data']['array_result']['nir'] median_result = e.cache['medianT']['array_result']['medianT'] b40_data = Data(x=b40_result[:, ::-1, :], label='B40') median_data = Data(x=median_result[::-1, :], label='medianT') long_data = Data(x=b40_result.coords['x'], label='long') lat_data = Data(x=b40_result.coords['y'], label='lat') time_data = Data(x=b40_result.coords['time'], label='time') collection = DataCollection([ median_data, b40_data, long_data, lat_data, time_data, ]) app = GlueApplication(collection) app.start()
def main(): a = AnalyticsEngine() e = ExecutionEngine() # Lake Burley Griffin dimensions = {'x': {'range': (149.07, 149.18)}, 'y': {'range': (-35.32, -35.28)}, 'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}} b40 = a.create_array(('LANDSAT_5', 'nbar'), ['nir'], dimensions, 'b40') b30 = a.create_array(('LANDSAT_5', 'nbar'), ['red'], dimensions, 'b30') pq = a.create_array(('LANDSAT_5', 'pqa'), ['pixelquality'], dimensions, 'pq') ndvi = a.apply_expression([b40, b30], '((array1 - array2) / (array1 + array2))', 'ndvi') mask = a.apply_expression([ndvi, pq], 'array1{(array2 == 32767) | (array2 == 16383) | (array2 == 2457)}', 'mask') median_t = a.apply_expression(mask, 'median(array1, 0)', 'medianT') result = e.execute_plan(a.plan) plot(e.cache['medianT']) b30_result = e.cache['b30']['array_result']['red'] b40_result = e.cache['b40']['array_result']['nir'] ndvi_result = e.cache['ndvi']['array_result']['ndvi'] pq_result = e.cache['pq']['array_result']['pixelquality'] mask_result = e.cache['mask']['array_result']['mask'] median_result = e.cache['medianT']['array_result']['medianT'] b30_data = Data(x=b30_result[:, ::-1, :], label='B30') b40_data = Data(x=b40_result[:, ::-1, :], label='B40') ndvi_data = Data(x=ndvi_result[:, ::-1, :], label='ndvi') pq_data = Data(x=pq_result[:, ::-1, :], label='pq') mask_data = Data(x=mask_result[:, ::-1, :], label='mask') median_data = Data(x=median_result[::-1, :], label='median') long_data = Data(x=b40_result.coords['x'], label='long') lat_data = Data(x=b40_result.coords['y'], label='lat') time_data = Data(x=b40_result.coords['time'], label='time') collection = DataCollection([median_data, mask_data, pq_data, ndvi_data, b30_data, b40_data, long_data, lat_data, time_data, ]) app = GlueApplication(collection) app.start()
def main(): a = AnalyticsEngine() e = ExecutionEngine() # Lake Burley Griffin dimensions = {'x': {'range': (149.07, 149.18)}, 'y': {'range': (-35.32, -35.28)}, 'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}} b40 = a.create_array(('LANDSAT_5', 'nbar'), ['nir'], dimensions, 'b40') b30 = a.create_array(('LANDSAT_5', 'nbar'), ['red'], dimensions, 'b30') pq = a.create_array(('LANDSAT_5', 'pqa'), ['pixelquality'], dimensions, 'pq') ndvi = a.apply_expression([b40, b30], '((array1 - array2) / (array1 + array2))', 'ndvi') mask = a.apply_expression([ndvi, pq], 'array1{(array2 == 32767) | (array2 == 16383) | (array2 == 2457)}', 'mask') median_t = a.apply_expression(mask, 'median(array1, 0)', 'medianT') result = e.execute_plan(a.plan) plot(e.cache['medianT']) b30_result = e.cache['b30']['array_result']['red'] b40_result = e.cache['b40']['array_result']['nir'] ndvi_result = e.cache['ndvi']['array_result']['ndvi'] pq_result = e.cache['pq']['array_result']['pixelquality'] mask_result = e.cache['mask']['array_result']['mask'] median_result = e.cache['medianT']['array_result']['medianT'] b30_data = Data(x=b30_result[:, ::-1, :], label='B30') b40_data = Data(x=b40_result[:, ::-1, :], label='B40') ndvi_data = Data(x=ndvi_result[:, ::-1, :], label='ndvi') pq_data = Data(x=pq_result[:, ::-1, :], label='pq') mask_data = Data(x=mask_result[:, ::-1, :], label='mask') median_data = Data(x=median_result[::-1, :], label='median') long_data = Data(x=b40_result.coords['x'], label='long') lat_data = Data(x=b40_result.coords['y'], label='lat') time_data = Data(x=b40_result.coords['time'], label='time') collection = DataCollection([median_data, mask_data, pq_data, ndvi_data, b30_data, b40_data, long_data, lat_data, time_data, ]) app = GlueApplication(collection) app.start()
def main(): a = AnalyticsEngine() e = ExecutionEngine() # Lake Burley Griffin dimensions = {'x': {'range': (149.07, 149.18)}, 'y': {'range': (-35.32, -35.28)}, 'time': {'range': (datetime(1990, 1, 1), datetime(1990, 12, 31))}} arrays = a.create_array(('LANDSAT_5', 'nbar'), ['nir', 'red'], dimensions, 'get_data') ndvi = a.apply_bandmath(arrays, '((array1 - array2) / (array1 + array2))', 'ndvi') pq = a.create_array(('LANDSAT_5', 'pqa'), ['pixelquality'], dimensions, 'pq') mask = a.apply_cloud_mask(ndvi, pq, 'mask') e.execute_plan(a.plan) plot(e.cache['mask']) b30_result = e.cache['get_data']['array_result']['red'] b40_result = e.cache['get_data']['array_result']['nir'] ndvi_result = e.cache['ndvi']['array_result']['ndvi'] pq_result = e.cache['pq']['array_result']['pixelquality'] mask_result = e.cache['mask']['array_result']['mask'] b30_data = Data(x=b30_result[:, ::-1, :], label='B30') b40_data = Data(x=b40_result[:, ::-1, :], label='B40') ndvi_data = Data(x=ndvi_result[:, ::-1, :], label='ndvi') pq_data = Data(x=pq_result[:, ::-1, :], label='pq') mask_data = Data(x=mask_result[:, ::-1, :], label='mask') long_data = Data(x=b40_result.coords['x'], label='long') lat_data = Data(x=b40_result.coords['y'], label='lat') time_data = Data(x=b40_result.coords['time'], label='time') collection = DataCollection([mask_data, pq_data, ndvi_data, b30_data, b40_data, long_data, lat_data, time_data, ]) app = GlueApplication(collection) app.start()
def AJAXHandle(request): if request.is_ajax(): year = int(request.POST['year']) layer = request.POST['layer'] epsg = request.POST['epsg'] prod = request.POST['prod'] algo = request.POST['algo'] x1 = float(request.POST['x1']) x2 = float(request.POST['x2']) y1 = float(request.POST['y1']) y2 = float(request.POST['y2']) utm44 = pyproj.Proj("+init=EPSG:32644") gcs = pyproj.Proj("+init=EPSG:4326") x1, y1 = pyproj.transform(gcs, utm44, x1, y1) x2, y2 = pyproj.transform(gcs, utm44, x2, y2) print x1, x2, y1, y2 imsource = plot(year,layer,x1,x2,y1,y2,epsg,prod,algo) response = {'status': 1, 'message': imsource + "?t=" + str(random.randint(1,1000))} else: response = {'status': 0, 'message': "error"} return HttpResponse(json.dumps(response), content_type='application/json')