Skip to content

Commit 04b5472

Browse files
8.1.5
1 parent 7cbac32 commit 04b5472

9 files changed

Lines changed: 16733 additions & 16710 deletions

File tree

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def description():
3434

3535

3636
def version():
37-
return 'Version 8.1.4 - Infinity'
37+
return 'Version 8.1.5 - Infinity'
3838

3939

4040
def icon():

core/ui_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def update_bar(
251251
str(err)
252252

253253
# remove progress bar and cancel button
254-
def remove_progress_bar(self, smtp=None):
254+
def remove_progress_bar(self, smtp=None, sound=None):
255255
UiUtils.remaining = ''
256256
try:
257257
cfg.iface.messageBar().popWidget(UiUtils.widget_bar)
@@ -268,7 +268,8 @@ def remove_progress_bar(self, smtp=None):
268268
subject=self.translate('Semi-Automatic Classification Plugin'),
269269
message=self.translate('%s: process finished' % smtp)
270270
)
271-
self.finish_sound()
271+
if sound is not False:
272+
self.finish_sound()
272273

273274
# translate
274275
@staticmethod

core/util_qgis.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,10 @@ def move_layer_to_top(layer):
226226
try:
227227
root = get_qgis_project().layerTreeRoot()
228228
layer = root.findLayer(layer.id())
229+
parent = layer.parent()
229230
layer_clone = layer.clone()
230231
root.insertChildNode(0, layer_clone)
231-
root.removeChildNode(layer)
232+
parent.removeChildNode(layer)
232233
except Exception as err:
233234
str(err)
234235

docs/repository.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version = '1.0' encoding = 'UTF-8'?>
22
<plugins>
3-
<pyqgis_plugin name="Semi-Automatic Classification Plugin - master" version="8.1.4" plugin_id="284">
3+
<pyqgis_plugin name="Semi-Automatic Classification Plugin - master" version="8.1.5" plugin_id="284">
44
<description><![CDATA[The Semi-Automatic Classification Plugin (SCP) allows for the supervised classification of remote sensing images, providing tools for the download, the preprocessing and postprocessing of images.]]></description>
55
<about><![CDATA[Developed by Luca Congedo, the Semi-Automatic Classification Plugin (SCP) allows for the supervised classification of remote sensing images, providing tools for the download, the preprocessing and postprocessing of images. Search and download is available for Landsat, Sentinel-2 images. Several algorithms are available for the land cover classification. This plugin requires the installation of Remotior Sensus, GDAL, OGR, Numpy, SciPy, and Matplotlib. For more information please visit https://fromgistors.blogspot.com .]]></about>
6-
<version>8.1.4</version>
6+
<version>8.1.5</version>
77
<qgis_minimum_version>3.0.0</qgis_minimum_version>
88
<qgis_maximum_version>3.99.0</qgis_maximum_version>
99
<homepage><![CDATA[https://fromgistors.blogspot.com/p/semi-automatic-classification-plugin.html]]></homepage>

interface/classification_tab.py

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,12 @@ def run_classifier(
375375
# classification
376376
if preview_point is None:
377377
bandset = bandset_number
378+
finish_sound = True
379+
smtp = str(__name__)
378380
# classification preview
379381
else:
382+
finish_sound = False
383+
smtp = None
380384
cfg.logger.log.debug(
381385
'preview_point x: %s; y: %s'
382386
% (str(preview_point.x()),
@@ -455,27 +459,34 @@ def run_classifier(
455459
# load classifier
456460
load_classifier = cfg.classifier_preview
457461
# run classification
458-
output = cfg.rs.band_classification(
459-
input_bands=bandset, output_path=output_path,
460-
spectral_signatures=signature_catalog,
461-
macroclass=macroclass, algorithm_name=classifier_name,
462-
bandset_catalog=cfg.bandset_catalog, threshold=threshold,
463-
signature_raster=signature_raster, cross_validation=cross_validation,
464-
input_normalization=input_normalization,
465-
load_classifier=load_classifier, class_weight=class_weight,
466-
find_best_estimator=find_best_estimator,
467-
rf_max_features=rf_max_features, rf_number_trees=rf_number_trees,
468-
rf_min_samples_split=rf_min_samples_split,
469-
svm_c=svm_c, svm_gamma=svm_gamma, svm_kernel=svm_kernel,
470-
mlp_training_portion=mlp_training_portion,
471-
mlp_alpha=mlp_alpha, mlp_learning_rate_init=mlp_learning_rate_init,
472-
mlp_max_iter=mlp_max_iter, mlp_batch_size=mlp_batch_size,
473-
mlp_activation=mlp_activation,
474-
mlp_hidden_layer_sizes=mlp_hidden_layer_sizes,
475-
classification_confidence=classification_confidence,
476-
only_fit=only_fit, save_classifier=save_classifier
477-
)
478-
if output.check:
462+
try:
463+
output = cfg.rs.band_classification(
464+
input_bands=bandset, output_path=output_path,
465+
spectral_signatures=signature_catalog,
466+
macroclass=macroclass, algorithm_name=classifier_name,
467+
bandset_catalog=cfg.bandset_catalog, threshold=threshold,
468+
signature_raster=signature_raster,
469+
cross_validation=cross_validation,
470+
input_normalization=input_normalization,
471+
load_classifier=load_classifier, class_weight=class_weight,
472+
find_best_estimator=find_best_estimator,
473+
rf_max_features=rf_max_features, rf_number_trees=rf_number_trees,
474+
rf_min_samples_split=rf_min_samples_split,
475+
svm_c=svm_c, svm_gamma=svm_gamma, svm_kernel=svm_kernel,
476+
mlp_training_portion=mlp_training_portion,
477+
mlp_alpha=mlp_alpha, mlp_learning_rate_init=mlp_learning_rate_init,
478+
mlp_max_iter=mlp_max_iter, mlp_batch_size=mlp_batch_size,
479+
mlp_activation=mlp_activation,
480+
mlp_hidden_layer_sizes=mlp_hidden_layer_sizes,
481+
classification_confidence=classification_confidence,
482+
only_fit=only_fit, save_classifier=save_classifier
483+
)
484+
except Exception as err:
485+
cfg.logger.log.error(str(err))
486+
cfg.mx.msg_err_1()
487+
if output is None:
488+
cfg.mx.msg_err_1()
489+
elif output.check:
479490
if save_classifier is not True and preview_point is None:
480491
output_raster = output.path
481492
# add raster to layers
@@ -510,7 +521,7 @@ def run_classifier(
510521
str(err)
511522
else:
512523
cfg.mx.msg_err_1()
513-
cfg.ui_utils.remove_progress_bar(smtp=str(__name__))
524+
cfg.ui_utils.remove_progress_bar(smtp=smtp, sound=finish_sound)
514525
return output
515526

516527

interface/scp_dock.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ def calculate_signatures():
12321232
)
12331233
cfg.ui_utils.add_progress_bar()
12341234
cfg.scp_training.calculate_signature_of_selected_signatures()
1235-
cfg.ui_utils.remove_progress_bar()
1235+
cfg.ui_utils.remove_progress_bar(sound=False)
12361236
cfg.dock_class_dlg.ui.undo_save_Button.setEnabled(True)
12371237
cfg.dock_class_dlg.ui.redo_save_Button.setEnabled(False)
12381238
# create table tree
@@ -1249,7 +1249,11 @@ def merge_signatures():
12491249
if len(selected) > 0:
12501250
answer = cfg.util_qt.question_box(
12511251
cfg.translate('Merge signatures'),
1252-
cfg.translate('Merge highlighted signatures?')
1252+
'%s MC ID: %s and C ID:%s?' % (
1253+
cfg.translate('Merge highlighted signatures into'),
1254+
cfg.project_registry[cfg.reg_roi_class_id],
1255+
cfg.project_registry[cfg.reg_roi_macroclass_id],
1256+
)
12531257
)
12541258
if answer is True:
12551259
# save previous catalog file
@@ -1260,7 +1264,7 @@ def merge_signatures():
12601264
)
12611265
cfg.ui_utils.add_progress_bar()
12621266
cfg.scp_training.merge_selected_signatures()
1263-
cfg.ui_utils.remove_progress_bar()
1267+
cfg.ui_utils.remove_progress_bar(sound=False)
12641268
cfg.dock_class_dlg.ui.undo_save_Button.setEnabled(True)
12651269
cfg.dock_class_dlg.ui.redo_save_Button.setEnabled(False)
12661270
# create table tree
@@ -2019,7 +2023,7 @@ def save_roi_to_training(bandset_number=None):
20192023
# save training input
20202024
if cfg.project_registry[cfg.reg_save_training_input_check] == 2:
20212025
cfg.scp_training.save_signature_catalog()
2022-
cfg.ui_utils.remove_progress_bar()
2026+
cfg.ui_utils.remove_progress_bar(sound=False)
20232027

20242028

20252029
# undo training modifications
@@ -2203,7 +2207,7 @@ def calculate_pixel_signature(point, bandset_number=None):
22032207
except Exception as err:
22042208
cfg.logger.log.error(str(err))
22052209
cfg.mx.msg_err_6()
2206-
cfg.ui_utils.remove_progress_bar()
2210+
cfg.ui_utils.remove_progress_bar(sound=False)
22072211
return False
22082212
bandset = cfg.bandset_catalog.get(bandset_number)
22092213
if bandset is None:
@@ -2229,7 +2233,7 @@ def calculate_pixel_signature(point, bandset_number=None):
22292233
)
22302234
(value_list, standard_deviation_list, wavelength_list,
22312235
pixel_count) = signature_catalog.calculate_signature(roi_path)
2232-
cfg.ui_utils.remove_progress_bar()
2236+
cfg.ui_utils.remove_progress_bar(sound=False)
22332237
plot_catalog = cfg.spectral_signature_plotter.plot_catalog
22342238
signature_id = generate_signature_id()
22352239
color_string = cfg.rs.shared_tools.random_color()
@@ -2274,7 +2278,7 @@ def create_region_growing_roi(point, bandset_number=None):
22742278
except Exception as err:
22752279
cfg.logger.log.error(str(err))
22762280
cfg.mx.msg_err_6()
2277-
cfg.ui_utils.remove_progress_bar()
2281+
cfg.ui_utils.remove_progress_bar(sound=False)
22782282
return False
22792283
# create memory temp ROI
22802284
region_crs = cfg.util_gdal.get_crs_gdal(region_path)
@@ -2324,7 +2328,7 @@ def create_region_growing_roi(point, bandset_number=None):
23242328
temporary_roi_spectral_signature(bandset_number=bandset_number)
23252329
cfg.dock_class_dlg.ui.button_Save_ROI.setEnabled(True)
23262330
cfg.redo_ROI_Button.setEnabled(True)
2327-
cfg.ui_utils.remove_progress_bar()
2331+
cfg.ui_utils.remove_progress_bar(sound=False)
23282332

23292333

23302334
# calculate temporary ROI spectral signature
@@ -2348,7 +2352,7 @@ def temporary_roi_spectral_signature(bandset_number=None, roi_path=None):
23482352
# add signature to plot
23492353
(value_list, standard_deviation_list, wavelength_list,
23502354
pixel_count) = signature_catalog.calculate_signature(roi_path)
2351-
cfg.ui_utils.remove_progress_bar()
2355+
cfg.ui_utils.remove_progress_bar(sound=False)
23522356
plot_catalog = cfg.spectral_signature_plotter.plot_catalog
23532357
signature_id = generate_signature_id()
23542358
color_string = cfg.rs.shared_tools.random_color()
@@ -2620,7 +2624,7 @@ def add_signature_to_spectral_plot(tab_index=0):
26202624
signature_catalog.export_signature_values_for_plot(
26212625
signature_id=_id, plot_catalog=plot_catalog
26222626
)
2623-
cfg.ui_utils.remove_progress_bar()
2627+
cfg.ui_utils.remove_progress_bar(sound=False)
26242628
cfg.spectral_signature_plotter.signature_list_plot_table()
26252629
cfg.input_interface.spectral_plot_tab()
26262630
cfg.input_interface.select_spectral_plot_settings_tab(tab_index)

metadata.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name=Semi-Automatic Classification Plugin
33
qgisMinimumVersion=3.00
44
description=The Semi-Automatic Classification Plugin (SCP) allows for the supervised classification of remote sensing images, providing tools for the download, the preprocessing and postprocessing of images.
5-
version=8.1.4
5+
version=8.1.5
66
about=Developed by Luca Congedo, the Semi-Automatic Classification Plugin (SCP) allows for the supervised classification of remote sensing images, providing tools for the download, the preprocessing and postprocessing of images. Search and download is available for Landsat, Sentinel-2 images. Several algorithms are available for the land cover classification. This plugin requires the installation of Remotior Sensus, GDAL, OGR, Numpy, SciPy, and Matplotlib. For more information please visit https://fromgistors.blogspot.com .
77

88
author=Luca Congedo
@@ -13,6 +13,12 @@ icon=semiautomaticclassificationplugin.png
1313

1414
changelog=
1515

16+
8.1.5
17+
-added information message when merging ROIs
18+
-minor fixes classification tab
19+
-fixed move layer to top
20+
-fixed finish sound
21+
1622
8.1.4
1723
-fixed finish sound
1824

spectral_signature/signature_importer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def library_changed(self):
116116
check, output = cfg.rs.download_tools.download_file(
117117
link, temp_path, timeout=2
118118
)
119-
cfg.ui_utils.remove_progress_bar()
119+
cfg.ui_utils.remove_progress_bar(sound=False)
120120
if check is True:
121121
description = open(temp_path, 'r', errors='ignore')
122122
description_html = description.read()
@@ -146,7 +146,7 @@ def download_library(link):
146146
except Exception as err:
147147
str(err)
148148
check = False
149-
cfg.ui_utils.remove_progress_bar()
149+
cfg.ui_utils.remove_progress_bar(sound=False)
150150
if check is False:
151151
cfg.mx.msg_err_5()
152152
return None, None, None

0 commit comments

Comments
 (0)