def calculate_on_GEE(self): self.close() crosses_180th, geojsons = self.gee_bounding_box payload = { 'year_baseline': self.lc_setup_tab.use_esa_bl_year.date().year(), 'year_target': self.lc_setup_tab.use_esa_tg_year.date().year(), 'geojsons': json.dumps(geojsons), 'crs': self.aoi.get_crs_dst_wkt(), 'crosses_180th': crosses_180th, 'trans_matrix': self.lc_define_deg_tab.trans_matrix_get(), 'remap_matrix': self.lc_setup_tab.dlg_esa_agg.get_agg_as_list(), 'task_name': self.options_tab.task_name.text(), 'task_notes': self.options_tab.task_notes.toPlainText() } resp = run_script(get_script_slug('land-cover'), payload) if resp: mb.pushMessage( self.tr("Submitted"), self.tr("Land cover task submitted to Google Earth Engine."), level=0, duration=5) else: mb.pushMessage( self.tr("Error"), self. tr("Unable to submit land cover task to Google Earth Engine."), level=0, duration=5)
def btn_calculate(self): # Note that the super class has several tests in it - if they fail it # returns False, which would mean this function should stop execution # as well. ret = super(DlgCalculateSOC, self).btn_calculate() if not ret: return self.close() payload = {'year_start': self.year_start.date().year(), 'year_end': self.year_end.date().year(), 'fl': self.get_fl(), 'download_annual_soc': self.download_annual_soc.isChecked(), 'download_annual_lc': self.download_annual_lc.isChecked(), 'geojson': json.dumps(self.aoi.bounding_box_geojson), 'remap_matrix': self.remap_matrix, 'task_name': self.task_name.text(), 'task_notes': self.task_notes.toPlainText()} gee_script = 'soil-organic-carbon' + '-' + self.scripts['soil-organic-carbon']['script version'] resp = run_script(gee_script, payload) if resp: mb.pushMessage(QtGui.QApplication.translate("LDMP", "Submitted"), QtGui.QApplication.translate("LDMP", "Soil organic carbon submitted to Google Earth Engine."), level=0, duration=5) else: mb.pushMessage(QtGui.QApplication.translate("LDMP", "Error"), QtGui.QApplication.translate("LDMP", "Unable to submit soil organic carbon task to Google Earth Engine."), level=0, duration=5)
def calculate_on_GEE(self): self.close() crosses_180th, geojsons = self.gee_bounding_box payload = {'un_adju': self.get_pop_def_is_un(), 'isi_thr': self.spinBox_isi_thr.value(), 'ntl_thr': self.spinBox_ntl_thr.value(), 'wat_thr': self.spinBox_wat_thr.value(), 'cap_ope': self.spinBox_cap_ope.value(), 'pct_suburban': self.spinBox_pct_suburban.value()/100., 'pct_urban': self.spinBox_pct_urban.value()/100., 'geojsons': json.dumps(geojsons), 'crs': self.aoi.get_crs_dst_wkt(), 'crosses_180th': crosses_180th, 'task_name': self.options_tab.task_name.text(), 'task_notes': self.options_tab.task_notes.toPlainText()} resp = run_script(get_script_slug('urban-area'), payload) if resp: mb.pushMessage(self.tr("Submitted"), self.tr("Urban area change calculation submitted to Google Earth Engine."), level=0, duration=5) else: mb.pushMessage(self.tr("Error"), self.tr("Unable to submit urban area task to Google Earth Engine."), level=0, duration=5)
def calculate_on_GEE(self): self.close() crosses_180th, geojsons = self.aoi.bounding_box_gee_geojson() payload = { 'length_yr': self.spinBox_years.value(), 'rest_type': self.get_rest_type(), 'geojsons': json.dumps(geojsons), 'crs': self.aoi.get_crs_dst_wkt(), 'crosses_180th': crosses_180th, 'task_name': self.options_tab.task_name.text(), 'task_notes': self.options_tab.task_notes.toPlainText() } resp = run_script(get_script_slug('restoration-biomass'), payload) if resp: mb.pushMessage( QtWidgets.QApplication.translate("LDMP", "Submitted"), QtWidgets.QApplication.translate( "LDMP", "Restoration biomass change submitted to Google Earth Engine." ), level=0, duration=5) else: mb.pushMessage( QtWidgets.QApplication.translate("LDMP", "Error"), QtWidgets.QApplication.translate( "LDMP", "Unable to submit restoration biomass change task to Google Earth Engine." ), level=0, duration=5)
def calculate_on_GEE(self, method, biomass_data): self.close() crosses_180th, geojsons = self.aoi.bounding_box_gee_geojson() payload = {'year_start': self.hansen_bl_year.date().year(), 'year_end': self.hansen_tg_year.date().year(), 'fc_threshold': int(self.hansen_fc_threshold.text().replace('%', '')), 'method': method, 'biomass_data': biomass_data, 'geojsons': json.dumps(geojsons), 'crs': self.aoi.get_crs_dst_wkt(), 'crosses_180th': crosses_180th, 'task_name': self.options_tab.task_name.text(), 'task_notes': self.options_tab.task_notes.toPlainText()} resp = run_script(get_script_slug('total-carbon'), payload) if resp: mb.pushMessage(QtWidgets.QApplication.translate("LDMP", "Submitted"), QtWidgets.QApplication.translate("LDMP", "Total carbon submitted to Google Earth Engine."), level=0, duration=5) else: mb.pushMessage(QtWidgets.QApplication.translate("LDMP", "Error"), QtWidgets.QApplication.translate("LDMP", "Unable to submit total carbon task to Google Earth Engine."), level=0, duration=5)
def calculate_timeseries(self, geojson, ndvi_dataset): if self.traj_climate.currentText() != "": climate_gee_dataset = self.climate_datasets[self.traj_climate.currentText()]['GEE Dataset'] log('climate_gee_dataset {}'.format(climate_gee_dataset)) else: climate_gee_dataset = None payload = {'year_start': self.traj_year_start.date().year(), 'year_end': self.traj_year_end.date().year(), 'geojson': json.dumps(geojson), 'ndvi_gee_dataset': ndvi_dataset, 'task_name': self.task_name.text(), 'climate_gee_dataset': climate_gee_dataset} # This will add in the method parameter payload.update(self.scripts['productivity-trajectory']['functions'][self.traj_indic.currentText()]['params']) gee_script = 'time-series' + '-' + self.scripts['time-series']['script version'] resp = run_script(gee_script, payload) if resp: mb.pushMessage(self.tr("Submitted"), self.tr("Time series calculation task submitted to Google Earth Engine."), level=0, duration=5) else: mb.pushMessage(self.tr("Error"), self.tr("Unable to submit time series calculation task to Google Earth Engine."), level=1, duration=5)
def calculate_performance(self, geojson, ndvi_dataset): payload = { 'year_start': self.perf_year_start.date().year(), 'year_end': self.perf_year_end.date().year(), 'geojson': json.dumps(geojson), 'ndvi_gee_dataset': ndvi_dataset, 'task_name': self.task_name.text(), 'task_notes': self.task_notes.toPlainText() } gee_script = self.scripts['productivity_performance']['script id'] resp = run_script(gee_script, payload) if resp: mb.pushMessage( QtGui.QApplication.translate("LDMP", "Submitted"), QtGui.QApplication.translate( "LDMP", "Productivity performance task submitted to Google Earth Engine." ), level=0, duration=5) else: mb.pushMessage( QtGui.QApplication.translate("LDMP", "Error"), QtGui.QApplication.translate( "LDMP", "Unable to submit productivity performance task to Google Earth Engine." ), level=0, duration=5)
def calculate_on_GEE(self): self.close() crosses_180th, geojsons = self.aoi.bounding_box_gee_geojson() payload = {'year_start': self.lc_setup_tab.use_esa_bl_year.date().year(), 'year_end': self.lc_setup_tab.use_esa_tg_year.date().year(), 'fl': self.get_fl(), 'download_annual_lc': self.download_annual_lc.isChecked(), 'geojsons': json.dumps(geojsons), 'crs': self.aoi.get_crs_dst_wkt(), 'crosses_180th': crosses_180th, 'remap_matrix': self.lc_setup_tab.dlg_esa_agg.get_agg_as_list(), 'task_name': self.options_tab.task_name.text(), 'task_notes': self.options_tab.task_notes.toPlainText()} resp = run_script(get_script_slug('soil-organic-carbon'), payload) if resp: mb.pushMessage(QtWidgets.QApplication.translate("LDMP", "Submitted"), QtWidgets.QApplication.translate("LDMP", "Soil organic carbon submitted to Google Earth Engine."), level=0, duration=5) else: mb.pushMessage(QtWidgets.QApplication.translate("LDMP", "Error"), QtWidgets.QApplication.translate("LDMP", "Unable to submit soil organic carbon task to Google Earth Engine."), level=0, duration=5)
def btn_calculate(self): self.close() # Note that the super class has several tests in it - if they fail it # returns False, which would mean this function should stop execution # as well. ret = super(DlgCalculateLC, self).btn_calculate() if not ret: return # Extract trans_matrix from the QTableWidget trans_matrix = [] for row in range(0, self.transMatrix.rowCount()): for col in range(0, self.transMatrix.columnCount()): val = self.transMatrix.cellWidget(row, col).text() if val == "": val = 0 else: val = int(val) trans_matrix.append(val) payload = { 'year_bl_start': self.year_bl_start.date().year(), 'year_bl_end': self.year_bl_end.date().year(), 'year_target': self.year_target.date().year(), 'geojson': json.dumps(self.bbox), 'trans_matrix': trans_matrix, 'remap_matrix': self.remap_matrix, 'task_name': self.task_name.text(), 'task_notes': self.task_notes.toPlainText() } gee_script = self.scripts['land_cover']['Land cover']['script id'] resp = run_script(gee_script, payload) if resp: mb.pushMessage( QtGui.QApplication.translate("LDMP", "Submitted"), QtGui.QApplication.translate( "LDMP", "Land cover task submitted to Google Earth Engine."), level=0, duration=5) else: mb.pushMessage( QtGui.QApplication.translate("LDMP", "Error"), QtGui.QApplication.translate( "LDMP", "Unable to submit land cover task to Google Earth Engine." ), level=0, duration=5)
def btn_calculate(self): # Note that the super class has several tests in it - if they fail it # returns False, which would mean this function should stop execution # as well. ret = super(DlgTimeseries, self).btn_calculate() if not ret: return self.close() if self.traj_climate.currentText() != "": climate_gee_dataset = self.climate_datasets[ self.traj_climate.currentText()]['GEE Dataset'] log('climate_gee_dataset {}'.format(climate_gee_dataset)) else: climate_gee_dataset = None ndvi_dataset = self.datasets['NDVI'][ self.dataset_ndvi.currentText()]['GEE Dataset'] crosses_180th, geojsons = self.aoi.bounding_box_gee_geojson() payload = { 'year_start': self.traj_year_start.date().year(), 'year_end': self.traj_year_end.date().year(), 'crosses_180th': crosses_180th, 'geojsons': json.dumps(geojsons), 'crs': self.aoi.get_crs_dst_wkt(), 'ndvi_gee_dataset': ndvi_dataset, 'task_name': self.options_tab.task_name.text(), 'task_notes': self.options_tab.task_notes.toPlainText(), 'climate_gee_dataset': climate_gee_dataset } # This will add in the method parameter payload.update(self.scripts['productivity']['trajectory functions'][ self.traj_indic.currentText()]['params']) resp = run_script(get_script_slug('time-series'), payload) if resp: mb.pushMessage( self.tr("Submitted"), self. tr("Time series calculation task submitted to Google Earth Engine." ), level=0, duration=5) else: mb.pushMessage( self.tr("Error"), self. tr("Unable to submit time series calculation task to Google Earth Engine." ), level=1, duration=5)
def btn_calculate(self): # Note that the super class has several tests in it - if they fail it # returns False, which would mean this function should stop execution # as well. ret = super(DlgDownload, self).btn_calculate() if not ret: return rows = list( set(index.row() for index in self.data_view.selectedIndexes())) self.close() crosses_180th, geojsons = self.aoi.bounding_box_gee_geojson() for row in rows: payload = { 'geojsons': json.dumps(geojsons), 'crs': self.aoi.get_crs_dst_wkt(), 'year_start': self.first_year.date().year(), 'year_end': self.last_year.date().year(), 'crosses_180th': crosses_180th, 'asset': self.datasets[row]['GEE Dataset'], 'name': self.datasets[row]['title'], 'temporal_resolution': self.datasets[row]['Temporal resolution'], 'task_name': self.options_tab.task_name.text(), 'task_notes': self.options_tab.task_notes.toPlainText() } resp = run_script(get_script_slug('download-data'), payload) if resp: mb.pushMessage( QtWidgets.QApplication.translate("LDMP", "Success"), QtWidgets.QApplication.translate( "LDMP", "Download request submitted to Google Earth Engine."), level=0, duration=5) else: mb.pushMessage( QtWidgets.QApplication.translate("LDMP", "Error"), QtWidgets.QApplication.translate( "LDMP", "Unable to submit download request to Google Earth Engine." ), level=0, duration=5)
def calculate_trajectory(self, geojson, ndvi_dataset): if self.traj_climate.currentText() != "": climate_gee_dataset = self.climate_datasets[ self.traj_climate.currentText()]['GEE Dataset'] log('climate_gee_dataset {}'.format(climate_gee_dataset)) else: climate_gee_dataset = None payload = { 'year_start': self.traj_year_start.date().year(), 'year_end': self.traj_year_end.date().year(), 'geojson': json.dumps(self.aoi.bounding_box_geojson), 'ndvi_gee_dataset': ndvi_dataset, 'climate_gee_dataset': climate_gee_dataset, 'task_name': self.task_name.text(), 'task_notes': self.task_notes.toPlainText() } # This will add in the method parameter payload.update(self.scripts['productivity-trajectory']['functions'][ self.traj_indic.currentText()]['params']) # All of the productivity trajectory indicators are within the same # script - the "functions" are all within a single GEE script so they # all have the same script id. gee_script = 'productivity-trajectory' + '-' + self.scripts[ 'productivity-trajectory']['script version'] resp = run_script(gee_script, payload) if resp: mb.pushMessage( QtGui.QApplication.translate("LDMP", "Submitted"), QtGui.QApplication.translate( "LDMP", "Productivity trajectory task submitted to Google Earth Engine." ), level=0, duration=5) else: mb.pushMessage( QtGui.QApplication.translate("LDMP", "Error"), QtGui.QApplication.translate( "LDMP", "Unable to submit productivity trajectory task to Google Earth Engine." ), level=0, duration=5)
def calculate_trajectory(self, geojson, ndvi_dataset): if self.traj_climate.currentText() != "": climate_gee_dataset = self.climate_datasets[ self.traj_climate.currentText()]['GEE Dataset'] log('climate_gee_dataset {}'.format(climate_gee_dataset)) else: climate_gee_dataset = None payload = { 'year_start': self.traj_year_start.date().year(), 'year_end': self.traj_year_end.date().year(), 'geojson': json.dumps(self.bbox), 'ndvi_gee_dataset': ndvi_dataset, 'climate_gee_dataset': climate_gee_dataset, 'task_name': self.task_name.text(), 'task_notes': self.task_notes.toPlainText() } # This will add in the method parameter payload.update(self.scripts['productivity_trajectory'][ self.traj_indic.currentText()]['params']) gee_script = self.scripts['productivity_trajectory'][ self.traj_indic.currentText()]['script id'] resp = run_script(gee_script, payload) if resp: mb.pushMessage( QtGui.QApplication.translate("LDMP", "Submitted"), QtGui.QApplication.translate( "LDMP", "Productivity trajectory task submitted to Google Earth Engine." ), level=0, duration=5) else: mb.pushMessage( QtGui.QApplication.translate("LDMP", "Error"), QtGui.QApplication.translate( "LDMP", "Unable to submit productivity trajectory task to Google Earth Engine." ), level=0, duration=5)
def btn_calculate(self): # Note that the super class has several tests in it - if they fail it # returns False, which would mean this function should stop execution # as well. ret = super(DlgDownload, self).btn_calculate() if not ret: return rows = list( set(index.row() for index in self.data_view.selectedIndexes())) self.close() for row in rows: payload = { 'geojson': json.dumps(self.aoi.bounding_box_geojson), 'asset': self.datasets[row]['GEE Dataset'], 'task_name': self.task_name.text(), 'task_notes': self.task_notes.toPlainText() } gee_script = 'download-data' + '-' + self.scripts[ 'download-download']['script version'] resp = run_script(gee_script, payload) if resp: mb.pushMessage( QtGui.QApplication.translate("LDMP", "Sucess"), QtGui.QApplication.translate( "LDMP", "Download request submitted to Google Earth Engine."), level=0, duration=5) else: mb.pushMessage( QtGui.QApplication.translate("LDMP", "Error"), QtGui.QApplication.translate( "LDMP", "Unable to submit download request to Google Earth Engine." ), level=0, duration=5)
def btn_calculate(self): # Note that the super class has several tests in it - if they fail it # returns False, which would mean this function should stop execution # as well. ret = super(DlgCalculateLC, self).btn_calculate() if not ret: return self.close() payload = { 'year_baseline': self.year_baseline.date().year(), 'year_target': self.year_target.date().year(), 'geojson': json.dumps(self.aoi.bounding_box_geojson), 'trans_matrix': self.trans_matrix_get(), 'remap_matrix': self.remap_matrix, 'task_name': self.task_name.text(), 'task_notes': self.task_notes.toPlainText() } gee_script = 'land-cover' + '-' + self.scripts['land-cover'][ 'script version'] resp = run_script(gee_script, payload) if resp: mb.pushMessage( QtGui.QApplication.translate("LDMP", "Submitted"), QtGui.QApplication.translate( "LDMP", "Land cover task submitted to Google Earth Engine."), level=0, duration=5) else: mb.pushMessage( QtGui.QApplication.translate("LDMP", "Error"), QtGui.QApplication.translate( "LDMP", "Unable to submit land cover task to Google Earth Engine." ), level=0, duration=5)
def btn_calculate(self): # Note that the super class has several tests in it - if they fail it # returns False, which would mean this function should stop execution # as well. ret = super(DlgDownload, self).btn_calculate() if not ret: return rows = list(set(index.row() for index in self.data_view.selectedIndexes())) # Construct unique dataset names as the concatenation of the category # and the title selected_names = [self.proxy_model.index(row, 0).data() + self.proxy_model.index(row, 1).data()for row in rows] selected_datasets = [d for d in self.datasets if d['category'] + d['title'] in selected_names] self.close() crosses_180th, geojsons = self.gee_bounding_box for dataset in selected_datasets: payload = {'geojsons': json.dumps(geojsons), 'crs': self.aoi.get_crs_dst_wkt(), 'year_start': self.first_year.date().year(), 'year_end': self.last_year.date().year(), 'crosses_180th': crosses_180th, 'asset': dataset['GEE Dataset'], 'name': dataset['title'], 'temporal_resolution': dataset['Temporal resolution'], 'task_name': self.options_tab.task_name.text(), 'task_notes': self.options_tab.task_notes.toPlainText()} resp = run_script(get_script_slug('download-data'), payload) if resp: mb.pushMessage(self.tr("Success"), self.tr("Download request submitted to Google Earth Engine."), level=0, duration=5) else: mb.pushMessage(self.tr("Error"), self.tr("Unable to submit download request to Google Earth Engine."), level=0, duration=5)
def btn_calculate(self): if self.mode_te_prod.isChecked() \ and not (self.groupBox_traj.isChecked() or self.groupBox_perf.isChecked() or self.groupBox_state.isChecked()): QtWidgets.QMessageBox.critical(None, self.tr("Error"), self.tr("Choose one or more productivity sub-indicator to calculate."), None) return # Note that the super class has several tests in it - if they fail it # returns False, which would mean this function should stop execution # as well. ret = super(DlgCalculateProd, self).btn_calculate() if not ret: return self.close() ndvi_dataset = self.datasets['NDVI'][self.dataset_ndvi.currentText()]['GEE Dataset'] if self.traj_climate.currentText() != "": climate_gee_dataset = self.climate_datasets[self.traj_climate.currentText()]['GEE Dataset'] log(u'climate_gee_dataset {}'.format(climate_gee_dataset)) else: climate_gee_dataset = None if self.mode_te_prod.isChecked(): prod_mode = 'Trends.Earth productivity' else: prod_mode = 'JRC LPD' crosses_180th, geojsons = self.aoi.bounding_box_gee_geojson() payload = {'prod_mode': prod_mode, 'calc_traj': self.groupBox_traj.isChecked(), 'calc_perf': self.groupBox_perf.isChecked(), 'calc_state': self.groupBox_state.isChecked(), 'prod_traj_year_initial': self.traj_year_start.date().year(), 'prod_traj_year_final': self.traj_year_end.date().year(), 'prod_perf_year_initial': self.perf_year_start.date().year(), 'prod_perf_year_final': self.perf_year_end.date().year(), 'prod_state_year_bl_start': self.state_year_bl_start.date().year(), 'prod_state_year_bl_end': self.state_year_bl_end.date().year(), 'prod_state_year_tg_start': self.state_year_tg_start.date().year(), 'prod_state_year_tg_end': self.state_year_tg_end.date().year(), 'geojsons': json.dumps(geojsons), 'crs': self.aoi.get_crs_dst_wkt(), 'crosses_180th': crosses_180th, 'ndvi_gee_dataset': ndvi_dataset, 'climate_gee_dataset': climate_gee_dataset, 'task_name': self.options_tab.task_name.text(), 'task_notes': self.options_tab.task_notes.toPlainText()} # This will add in the trajectory-method parameter for productivity # trajectory payload.update(self.scripts['productivity']['trajectory functions'][self.traj_indic.currentText()]['params']) resp = run_script(get_script_slug('productivity'), payload) if resp: mb.pushMessage(QtWidgets.QApplication.translate("LDMP", "Submitted"), QtWidgets.QApplication.translate("LDMP", "Productivity task submitted to Google Earth Engine."), level=0, duration=5) else: mb.pushMessage(QtWidgets.QApplication.translate("LDMP", "Error"), QtWidgets.QApplication.translate("LDMP", "Unable to submit productivity task to Google Earth Engine."), level=0, duration=5)
def btn_calculate(self): # Note that the super class has several tests in it - if they fail it # returns False, which would mean this function should stop execution # as well. ret = super(DlgTimeseries, self).btn_calculate() if not ret: return self.close() # Limit area that can be processed aoi_area = self.aoi.get_area() / (1000 * 1000) log(u'AOI area is: {:n}'.format(aoi_area)) if aoi_area > 1e7: QtWidgets.QMessageBox.critical( None, self.tr("Error"), self. tr("The bounding box of the requested area (approximately {:.6n} sq km) is too large. The timeseries tool can process a maximum area of 10 million sq km at a time. Choose a smaller area to process." .format(aoi_area))) return False if self.traj_climate.currentText() != "": climate_gee_dataset = self.climate_datasets[ self.traj_climate.currentText()]['GEE Dataset'] log('climate_gee_dataset {}'.format(climate_gee_dataset)) else: climate_gee_dataset = None ndvi_dataset = self.datasets['NDVI'][ self.dataset_ndvi.currentText()]['GEE Dataset'] crosses_180th, geojsons = self.gee_bounding_box payload = { 'year_start': self.traj_year_start.date().year(), 'year_end': self.traj_year_end.date().year(), 'crosses_180th': crosses_180th, 'geojsons': json.dumps(geojsons), 'crs': self.aoi.get_crs_dst_wkt(), 'ndvi_gee_dataset': ndvi_dataset, 'task_name': self.options_tab.task_name.text(), 'task_notes': self.options_tab.task_notes.toPlainText(), 'climate_gee_dataset': climate_gee_dataset } # This will add in the method parameter payload.update(self.scripts['productivity']['trajectory functions'][ self.traj_indic.currentText()]['params']) resp = run_script(get_script_slug('time-series'), payload) if resp: mb.pushMessage( self.tr("Submitted"), self. tr("Time series calculation task submitted to Google Earth Engine." ), level=0, duration=5) else: mb.pushMessage( self.tr("Error"), self. tr("Unable to submit time series calculation task to Google Earth Engine." ), level=1, duration=5)