-
Notifications
You must be signed in to change notification settings - Fork 0
/
semiautomaticclassificationplugin.py
1496 lines (1482 loc) · 75.3 KB
/
semiautomaticclassificationplugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
"""
/**************************************************************************************************************************
SemiAutomaticClassificationPlugin
The Semi-Automatic Classification Plugin for QGIS allows for the supervised classification of remote sensing images,
providing tools for the download, the preprocessing and postprocessing of images.
-------------------
begin : 2012-12-29
copyright : (C) 2012-2017 by Luca Congedo
email : [email protected]
**************************************************************************************************************************/
/**************************************************************************************************************************
*
* This file is part of Semi-Automatic Classification Plugin
*
* Semi-Automatic Classification Plugin is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software Foundation,
* version 3 of the License.
*
* Semi-Automatic Classification Plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Semi-Automatic Classification Plugin. If not, see <http://www.gnu.org/licenses/>.
*
**************************************************************************************************************************/
"""
import os
import sys
import platform
import inspect
import shutil
import time
import datetime
import subprocess
import numpy as np
import urllib
import urllib2
import ssl
from cookielib import CookieJar
import itertools
import zipfile
import tarfile
import base64
import random
import re
import xml.etree.cElementTree as ET
from xml.dom import minidom
import hashlib
# Import the PyQt libraries
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import Qt, QObject, SIGNAL, QFileInfo, QSettings, QDir, QDate, QVariant
from PyQt4.QtGui import QApplication
from PyQt4.QtNetwork import QNetworkRequest
# Import the QGIS libraries
import qgis.core as qgisCore
from qgis.gui import *
import qgis.utils as qgisUtils
from osgeo import gdal
from osgeo import ogr
from osgeo import osr
# Initialize Qt ui
import ui.resources_rc
from ui.ui_semiautomaticclassificationplugin import Ui_SemiAutomaticClassificationPlugin
from ui.semiautomaticclassificationplugindialog import SemiAutomaticClassificationPluginDialog
from ui.semiautomaticclassificationplugindialog import SpectralSignatureDialog
from ui.semiautomaticclassificationplugindialog import ScatterPlotDialog
from ui.semiautomaticclassificationplugindialog import DockClassDialog
# Import plugin version
from __init__ import version as semiautomaticclassVersion
global PluginCheck
PluginCheck = "Yes"
try:
import core.config as cfg
except:
PluginCheck = "No"
if PluginCheck == "Yes":
try:
import core.messages as msgs
from core.utils import Utils
from core.signature_importer import Signature_Importer
from roidock.manualroi import ManualROI
from roidock.regionroi import RegionROI
from maininterface.downloadlandsatpointer import DownloadLandsatPointer
from maininterface.downloadasterpointer import DownloadASTERPointer
from maininterface.downloadmodispointer import DownloadMODISPointer
from maininterface.downloadsentinelpointer import DownloadSentinelPointer
from roidock.roidock import RoiDock
from spectralsignature.spectralsignatureplot import SpectralSignaturePlot
from spectralsignature.scatter_plot import Scatter_Plot
from classificationdock.classificationdock import ClassificationDock
from classificationdock.classificationpreview import ClassificationPreview
from maininterface.multipleroiTab import MultipleROITab
from spectralsignature.usgs_spectral_lib import USGS_Spectral_Lib
from maininterface.landsatTab import LandsatTab
from maininterface.asterTab import ASTERTab
from maininterface.modisTab import MODISTab
from maininterface.sentinelTab import Sentinel2Tab
from maininterface.accuracy import Accuracy
from maininterface.crossclassificationTab import CrossClassification
from maininterface.splitTab import SplitTab
from maininterface.pcaTab import PcaTab
from maininterface.vectortorasterTab import VectorToRasterTab
from maininterface.bandsetTab import BandsetTab
from maininterface.algorithmWeightTab import AlgWeightTab
from maininterface.signatureThresholdTab import SigThresholdTab
from maininterface.LCSignatureThresholdTab import LCSigThresholdTab
from maininterface.rgblistTab import RGBListTab
from maininterface.LCSignaturePixel import LCSigPixel
from maininterface.LCSignaturePixel2 import LCSigPixel2
from maininterface.bandcalcTab import BandCalcTab
from maininterface.batchTab import BatchTab
from maininterface.clipmultiplerasters import ClipMultipleRasters
from maininterface.stackrasterbands import StackRasterBands
from maininterface.editraster import EditRaster
from maininterface.sieveTab import SieveRaster
from maininterface.erosionTab import ErosionRaster
from maininterface.dilationTab import DilationRaster
from maininterface.downloadlandsatimages import DownloadLandsatImages
from maininterface.downloadasterimages import DownloadASTERImages
from maininterface.downloadmodisimages import DownloadMODISImages
from maininterface.downloadsentinelimages import DownloadSentinelImages
from maininterface.clipmultiplerasterspointer import ClipMultiplerastersPointer
from maininterface.landcoverchange import LandCoverChange
from maininterface.classreportTab import ClassReportTab
from maininterface.classtovectorTab import ClassToVectorTab
from maininterface.reclassificationTab import ReclassificationTab
from maininterface.settings import Settings
from core.input import Input
from ui.ui_utils import Ui_Utils
except:
PluginCheck = "No"
qgisUtils.iface.messageBar().pushMessage("Semi-Automatic Classification Plugin", QApplication.translate("semiautomaticclassificationplugin", "Please, restart QGIS for executing the Semi-Automatic Classification Plugin"), level=QgsMessageBar.INFO)
try:
import scipy.stats.distributions as statdistr
from scipy.spatial.distance import cdist
from scipy import signal
from scipy.ndimage import label
cfg.scipyCheck = "Yes"
except:
cfg.scipyCheck = "No"
try:
from matplotlib.ticker import MaxNLocator
import matplotlib.pyplot as mplplt
import matplotlib.colors as mplcolors
except Exception, err:
cfg.testMatplotlibV = err
class SemiAutomaticClassificationPlugin:
def __init__(self, iface):
try:
cfg.osSCP = os
cfg.sysSCP = sys
cfg.platformSCP = platform
cfg.shutilSCP = shutil
cfg.inspectSCP = inspect
cfg.timeSCP = time
cfg.datetimeSCP = datetime
cfg.subprocessSCP = subprocess
cfg.itertoolsSCP = itertools
cfg.zipfileSCP = zipfile
cfg.tarfileSCP = tarfile
cfg.base64SCP = base64
cfg.randomSCP = random
cfg.QtCoreSCP = QtCore
cfg.QtGuiSCP = QtGui
cfg.QNetworkRequestSCP = QNetworkRequest
cfg.QtSCP = Qt
cfg.QObjectSCP = QObject
cfg.QVariantSCP = QVariant
cfg.SIGNALSCP= SIGNAL
cfg.QFileInfoSCP = QFileInfo
cfg.QSettingsSCP = QSettings
cfg.QDirSCP = QDir
cfg.QDateSCP = QDate
cfg.qgisCoreSCP = qgisCore
cfg.gdalSCP = gdal
cfg.ogrSCP = ogr
cfg.osrSCP = osr
cfg.urllibSCP = urllib
cfg.urllib2SCP = urllib2
cfg.sslSCP = ssl
cfg.CookieJarSCP = CookieJar
cfg.reSCP = re
cfg.ETSCP = ET
cfg.minidomSCP = minidom
cfg.hashlibSCP = hashlib
cfg.statdistrSCP = statdistr
cfg.cdistSCP = cdist
cfg.signalSCP = signal
cfg.labelSCP = label
cfg.MaxNLocatorSCP = MaxNLocator
cfg.mplpltSCP = mplplt
cfg.mplcolorsSCP = mplcolors
cfg.np = np
except:
qgisUtils.iface.messageBar().pushMessage("Semi-Automatic Classification Plugin", QApplication.translate("semiautomaticclassificationplugin", "Please, restart QGIS for executing the Semi-Automatic Classification Plugin"), level=QgsMessageBar.INFO)
return
if PluginCheck == "Yes":
# reference to QGIS interface
cfg.iface = iface
# reference to map canvas
cfg.cnvs = iface.mapCanvas()
# reference to legend
cfg.lgnd = iface.legendInterface()
# create the dialog
cfg.dlg = SemiAutomaticClassificationPluginDialog()
# reference to ui
cfg.ui = cfg.dlg.ui
# class dock dialog
cfg.dockclassdlg = DockClassDialog(cfg.iface.mainWindow(), cfg.iface)
# reference dock class ui
cfg.uidc = cfg.dockclassdlg.ui
# spectral signature plot dialog
cfg.spectralplotdlg = SpectralSignatureDialog()
cfg.uisp = cfg.spectralplotdlg.ui
# scatter plot dialog
cfg.scatterplotdlg = ScatterPlotDialog()
cfg.uiscp = cfg.scatterplotdlg.ui
cfg.mx = msgs.Messages(cfg.iface)
cfg.utls = Utils()
cfg.ROId = RoiDock()
cfg.classD = ClassificationDock()
cfg.classPrev = ClassificationPreview(cfg.cnvs)
cfg.spSigPlot = SpectralSignaturePlot()
cfg.scaPlT = Scatter_Plot()
cfg.multiROI = MultipleROITab()
cfg.usgsLib = USGS_Spectral_Lib()
cfg.acc = Accuracy()
cfg.crossC = CrossClassification()
cfg.splitT = SplitTab()
cfg.pcaT = PcaTab()
cfg.vctRstrT = VectorToRasterTab()
cfg.bst = BandsetTab()
cfg.algWT = AlgWeightTab()
cfg.signT = SigThresholdTab()
cfg.LCSignT = LCSigThresholdTab()
cfg.RGBLT = RGBListTab()
cfg.bCalc = BandCalcTab()
cfg.batchT= BatchTab()
cfg.clipMulti = ClipMultipleRasters()
cfg.stackRstr = StackRasterBands()
cfg.editRstr = EditRaster()
cfg.sieveRstr = SieveRaster()
cfg.ersnRstr = ErosionRaster()
cfg.dltnRstr = DilationRaster()
cfg.downLandsat = DownloadLandsatImages()
cfg.downASTER = DownloadASTERImages()
cfg.downMODIS = DownloadMODISImages()
cfg.downSentinel = DownloadSentinelImages()
cfg.landsatT = LandsatTab()
cfg.ASTERT = ASTERTab()
cfg.MODIST = MODISTab()
cfg.sentinel2T = Sentinel2Tab()
cfg.landCC = LandCoverChange()
cfg.classRep = ClassReportTab()
cfg.classVect = ClassToVectorTab()
cfg.reclassification = ReclassificationTab()
cfg.sigImport = Signature_Importer()
cfg.mnlROI = ManualROI(cfg.cnvs)
cfg.regionROI = RegionROI(cfg.cnvs)
cfg.dwnlLandsatP = DownloadLandsatPointer(cfg.cnvs)
cfg.dwnlASTERP = DownloadASTERPointer(cfg.cnvs)
cfg.dwnlMODISP = DownloadMODISPointer(cfg.cnvs)
cfg.dwnlSentinelP = DownloadSentinelPointer(cfg.cnvs)
cfg.clipMultiP = ClipMultiplerastersPointer(cfg.cnvs)
cfg.LCSPixel = LCSigPixel(cfg.cnvs)
cfg.LCSPixel2 = LCSigPixel2(cfg.cnvs)
cfg.sets = Settings()
cfg.uiUtls = Ui_Utils()
cfg.ipt = Input()
# connect when map is clicked
cfg.iface.connect(cfg.mnlROI , cfg.SIGNALSCP("leftClicked") , cfg.ROId.clckL)
cfg.iface.connect(cfg.mnlROI , cfg.SIGNALSCP("rightClicked") , cfg.ROId.clckR)
cfg.iface.connect(cfg.mnlROI , cfg.SIGNALSCP("moved") , cfg.ROId.movedPointer)
cfg.iface.connect(cfg.regionROI , cfg.SIGNALSCP("ROIleftClicked") , cfg.ROId.pointerClickROI)
cfg.iface.connect(cfg.regionROI , cfg.SIGNALSCP("ROIrightClicked") , cfg.ROId.pointerRightClickROI)
cfg.iface.connect(cfg.dwnlLandsatP , cfg.SIGNALSCP("leftClicked") , cfg.downLandsat.pointerLeftClick)
cfg.iface.connect(cfg.dwnlLandsatP , cfg.SIGNALSCP("rightClicked") , cfg.downLandsat.pointerRightClick)
cfg.iface.connect(cfg.dwnlASTERP , cfg.SIGNALSCP("leftClicked") , cfg.downASTER.pointerLeftClick)
cfg.iface.connect(cfg.dwnlASTERP , cfg.SIGNALSCP("rightClicked") , cfg.downASTER.pointerRightClick)
cfg.iface.connect(cfg.dwnlMODISP , cfg.SIGNALSCP("leftClicked") , cfg.downMODIS.pointerLeftClick)
cfg.iface.connect(cfg.dwnlMODISP , cfg.SIGNALSCP("rightClicked") , cfg.downMODIS.pointerRightClick)
cfg.iface.connect(cfg.dwnlSentinelP , cfg.SIGNALSCP("leftClicked") , cfg.downSentinel.pointerLeftClick)
cfg.iface.connect(cfg.dwnlSentinelP , cfg.SIGNALSCP("rightClicked") , cfg.downSentinel.pointerRightClick)
cfg.iface.connect(cfg.clipMultiP , cfg.SIGNALSCP("leftClicked") , cfg.clipMulti.pointerLeftClick)
cfg.iface.connect(cfg.clipMultiP , cfg.SIGNALSCP("rightClicked") , cfg.clipMulti.pointerRightClick)
cfg.iface.connect(cfg.regionROI , cfg.SIGNALSCP("moved") , cfg.ROId.movedPointer)
cfg.iface.connect(cfg.classPrev , cfg.SIGNALSCP("leftClicked") , cfg.classD.pointerClickPreview)
cfg.iface.connect(cfg.classPrev , cfg.SIGNALSCP("rightClicked") , cfg.classD.pointerRightClickPreview)
cfg.iface.connect(cfg.LCSPixel , cfg.SIGNALSCP("MaprightClicked") , cfg.LCSignT.pointerLeftClick)
cfg.iface.connect(cfg.LCSPixel , cfg.SIGNALSCP("MapleftClicked") , cfg.LCSignT.pointerLeftClick)
cfg.iface.connect(cfg.LCSPixel2 , cfg.SIGNALSCP("MaprightClicked") , cfg.spSigPlot.pointerLeftClick)
cfg.iface.connect(cfg.LCSPixel2 , cfg.SIGNALSCP("MapleftClicked") , cfg.spSigPlot.pointerLeftClick)
# system variables
cfg.utls.findSystemSpecs()
cfg.utls.readVariables()
# initialize plugin directory
cfg.plgnDir = cfg.QFileInfoSCP(cfg.qgisCoreSCP.QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/" + str(__name__).split(".")[0]
# initialize LOG directory
cfg.lgndir = cfg.plgnDir
# log file path
cfg.logFile = cfg.lgndir.replace('//', '/') + "/__0semiautomaticclass.log"
# locale name
lclNm = cfg.QSettingsSCP().value("locale/userLocale")[0:2]
self.registryKeys()
""" temporary directory """
tmpDir = cfg.utls.getTempDirectory()
cfg.ui.temp_directory_label.setText(tmpDir)
""" locale """
lclPth = ""
if cfg.QFileInfoSCP(cfg.plgnDir).exists():
lclPth = cfg.plgnDir + "/i18n/semiautomaticclassificationplugin_" + lclNm + ".qm"
if cfg.QFileInfoSCP(lclPth).exists():
trnsltr = cfg.QtCoreSCP.QTranslator()
cfg.QtCoreSCP.QTextCodec.setCodecForTr(cfg.QtCoreSCP.QTextCodec.codecForName('utf-8'))
trnsltr.load(lclPth)
if cfg.QtCoreSCP.qVersion() > '4.3.3':
cfg.QtCoreSCP.QCoreApplication.installTranslator(trnsltr)
""" info """
cfg.sysSCPInfo = str(" SemiAutomaticClass " + semiautomaticclassVersion() + " - QGIS v. " + str(cfg.QGISVer) + " L:" + lclNm + " - OS " + str(cfg.sysSCPNm) + " - 64bit =" + cfg.sysSCP64bit)
# GDAL NUMBER of THREADS
try:
cfg.gdalSCP.SetConfigOption('GDAL_NUM_THREADS', 'ALL_CPUS')
except:
pass
# read registry keys
def registryKeys(self):
""" registry keys """
cfg.logSetVal = cfg.utls.readRegistryKeys(cfg.regLogKey, cfg.logSetVal)
cfg.logSetVal = cfg.utls.readRegistryKeys(cfg.regLogKey, cfg.logSetVal)
cfg.downNewsVal = cfg.utls.readRegistryKeys(cfg.downNewsKey, cfg.downNewsVal)
cfg.ROIClrVal = cfg.utls.readRegistryKeys(cfg.regROIClr, cfg.ROIClrVal)
cfg.ROITrnspVal = int(cfg.utls.readRegistryKeys(cfg.regROITransp, cfg.ROITrnspVal))
cfg.algFilesCheck = cfg.utls.readRegistryKeys(cfg.regAlgFiles, str(cfg.algFilesCheck))
cfg.outTempRastFormat = cfg.utls.readRegistryKeys(cfg.regTempRasterFormat, str(cfg.outTempRastFormat))
cfg.rasterCompression = cfg.utls.readRegistryKeys(cfg.regRasterCompression, str(cfg.rasterCompression))
cfg.RAMValue = int(cfg.utls.readRegistryKeys(cfg.regRAMValue, str(cfg.RAMValue)))
cfg.tmpDir = cfg.utls.readRegistryKeys(cfg.regTmpDir, cfg.tmpDir)
cfg.fldID_class = cfg.utls.readRegistryKeys(cfg.regIDFieldName, cfg.fldID_class)
cfg.fldMacroID_class = cfg.utls.readRegistryKeys(cfg.regMacroIDFieldName, cfg.fldMacroID_class)
cfg.macroclassCheck = cfg.utls.readRegistryKeys(cfg.regConsiderMacroclass, cfg.macroclassCheck)
cfg.LCsignatureCheckBox = cfg.utls.readRegistryKeys(cfg.regLCSignature, cfg.LCsignatureCheckBox)
cfg.fldROI_info = cfg.utls.readRegistryKeys(cfg.regInfoFieldName, cfg.fldROI_info)
cfg.fldROIMC_info = cfg.utls.readRegistryKeys(cfg.regMCInfoFieldName, cfg.fldROIMC_info)
cfg.variableName = cfg.utls.readRegistryKeys(cfg.regVariableName, cfg.variableName)
cfg.USGSUser = cfg.utls.readRegistryKeys(cfg.regUSGSUser, cfg.USGSUser)
cfg.USGSPass = cfg.utls.readRegistryKeys(cfg.regUSGSPass, cfg.USGSPass)
cfg.USGSUserASTER = cfg.utls.readRegistryKeys(cfg.regUSGSUserASTER, cfg.USGSUserASTER)
cfg.USGSPassASTER = cfg.utls.readRegistryKeys(cfg.regUSGSPassASTER, cfg.USGSPassASTER)
cfg.USGSUserMODIS = cfg.utls.readRegistryKeys(cfg.regUSGSUserMODIS, cfg.USGSUserMODIS)
cfg.USGSPassMODIS = cfg.utls.readRegistryKeys(cfg.regUSGSPassMODIS, cfg.USGSPassMODIS)
cfg.SciHubUser = cfg.utls.readRegistryKeys(cfg.regSciHubUser, cfg.SciHubUser)
cfg.SciHubService = cfg.utls.readRegistryKeys(cfg.regSciHubService, cfg.SciHubService)
cfg.SciHubPass = cfg.utls.readRegistryKeys(cfg.regSciHubPass, cfg.SciHubPass)
cfg.bndSetNm = cfg.utls.readRegistryKeys(cfg.regBandSetName, cfg.bndSetNm)
cfg.sigPLRoundCharList = cfg.roundCharList
cfg.scatPlRoundCharList = cfg.roundCharList
cfg.grpNm = cfg.utls.readRegistryKeys(cfg.regGroupName, cfg.grpNm)
cfg.rasterDataType = cfg.utls.readRegistryKeys(cfg.regRasterDataType, cfg.rasterDataType)
cfg.expressionListBC = cfg.utls.readRegistryKeys(cfg.regExpressionListBC, cfg.expressionListBC)
cfg.soundVal = cfg.utls.readRegistryKeys(cfg.regSound, cfg.soundVal)
def initGui(self):
if PluginCheck == "Yes":
try:
cfg.iface.addDockWidget(cfg.QtSCP.LeftDockWidgetArea, cfg.dockclassdlg)
except:
msg = ""
try:
import scipy.stats.distributions as statdistr
except:
msg = "SciPy"
try:
from matplotlib.ticker import MaxNLocator
except:
msg = "Matplotlib"
try:
import numpy as np
except:
msg = "NumPy"
try:
from osgeo import gdal
except:
msg = "Gdal"
qgisUtils.iface.messageBar().pushMessage("Semi-Automatic Classification Plugin", QApplication.translate("semiautomaticclassificationplugin", "Please, restart QGIS for executing the Semi-Automatic Classification Plugin. Possible missing dependecies: " + msg), level=QgsMessageBar.INFO)
return
cfg.ipt.loadInputToolbar()
cfg.algMinDist = cfg.uidc.algorithm_combo.itemText(0)
cfg.algML = cfg.uidc.algorithm_combo.itemText(1)
cfg.algSAM = cfg.uidc.algorithm_combo.itemText(2)
cfg.algName = cfg.algMinDist
cfg.uidc.algorithm_combo.setCurrentIndex(0)
# vector to raster type of conversion
cfg.ui.conversion_type_combo.addItem(cfg.convCenterPixels)
cfg.ui.conversion_type_combo.addItem(cfg.convAllPixelsTouch)
cfg.centerOfPixels = cfg.ui.conversion_type_combo.itemText(0)
""" menu """
cfg.ipt.loadMenu()
# set plugin version
cfg.ui.plugin_version_label.setText(semiautomaticclassVersion())
# signature list
cfg.utls.insertTableColumn(cfg.uidc.signature_list_tableWidget, 6, cfg.tableColString, None, "Yes")
cfg.utls.sortTableColumn(cfg.uidc.signature_list_tableWidget, 6)
cfg.utls.setColumnWidthList(cfg.uidc.signature_list_tableWidget, [[0, 30], [1, 30], [2, 40], [3, 40], [4, 50], [5, 40]])
# row height
cfg.ui.landsat_images_tableWidget.verticalHeader().setDefaultSectionSize(16)
cfg.ui.sentinel_images_tableWidget.verticalHeader().setDefaultSectionSize(16)
cfg.ui.tableWidget.verticalHeader().setDefaultSectionSize(16)
cfg.ui.tableWidget_band_calc.verticalHeader().setDefaultSectionSize(16)
cfg.ui.landsat_tableWidget.verticalHeader().setDefaultSectionSize(16)
cfg.ui.sentinel_2_tableWidget.verticalHeader().setDefaultSectionSize(16)
cfg.utls.setColumnWidthList(cfg.ui.sentinel_2_tableWidget, [[0, 400], [1, 200], [2, 60]])
cfg.ui.ASTER_tableWidget.verticalHeader().setDefaultSectionSize(16)
cfg.utls.setColumnWidthList(cfg.ui.ASTER_tableWidget, [[0, 400], [1, 200], [2, 60]])
cfg.ui.MODIS_tableWidget.verticalHeader().setDefaultSectionSize(16)
cfg.utls.setColumnWidthList(cfg.ui.MODIS_tableWidget, [[0, 400], [1, 200], [2, 60]])
cfg.ui.LCS_tableWidget.verticalHeader().setDefaultSectionSize(16)
cfg.ui.signature_threshold_tableWidget.verticalHeader().setDefaultSectionSize(16)
cfg.ui.tableWidget_weight.verticalHeader().setDefaultSectionSize(16)
cfg.ui.point_tableWidget.verticalHeader().setDefaultSectionSize(16)
try:
cfg.uidc.signature_list_tableWidget.horizontalHeader().setResizeMode(4, cfg.QtGuiSCP.QHeaderView.Stretch)
except:
pass
try:
cfg.uidc.macroclass_color_tableWidget.horizontalHeader().setResizeMode(1, cfg.QtGuiSCP.QHeaderView.Stretch)
except:
pass
# spectral signature plot list
cfg.utls.insertTableColumn(cfg.uisp.signature_list_plot_tableWidget, 6, cfg.tableColString, None, "Yes")
cfg.utls.sortTableColumn(cfg.uisp.signature_list_plot_tableWidget, 3)
cfg.utls.setColumnWidthList(cfg.uisp.signature_list_plot_tableWidget, [[0, 30], [1, 40], [2, 100], [3, 40], [4, 100], [5, 30]])
try:
cfg.uisp.signature_list_plot_tableWidget.horizontalHeader().setResizeMode(2, cfg.QtGuiSCP.QHeaderView.Stretch)
cfg.uisp.signature_list_plot_tableWidget.horizontalHeader().setResizeMode(4, cfg.QtGuiSCP.QHeaderView.Stretch)
except:
pass
# passwords
cfg.ui.password_usgs_lineEdit.setEchoMode(cfg.QtGuiSCP.QLineEdit.Password)
cfg.ui.password_usgs_lineEdit_2.setEchoMode(cfg.QtGuiSCP.QLineEdit.Password)
cfg.ui.password_usgs_lineEdit_3.setEchoMode(cfg.QtGuiSCP.QLineEdit.Password)
cfg.ui.password_scihub_lineEdit.setEchoMode(cfg.QtGuiSCP.QLineEdit.Password)
# scatter plot list
cfg.utls.insertTableColumn(cfg.uiscp.scatter_list_plot_tableWidget, 6, cfg.tableColString, None, "Yes")
cfg.utls.sortTableColumn(cfg.uiscp.scatter_list_plot_tableWidget, 3)
cfg.utls.setColumnWidthList(cfg.uiscp.scatter_list_plot_tableWidget, [[0, 30], [1, 40], [2, 100], [3, 40], [4, 100], [5, 30]])
try:
cfg.uiscp.scatter_list_plot_tableWidget.horizontalHeader().setResizeMode(2, cfg.QtGuiSCP.QHeaderView.Stretch)
cfg.uiscp.scatter_list_plot_tableWidget.horizontalHeader().setResizeMode(4, cfg.QtGuiSCP.QHeaderView.Stretch)
except:
pass
# signature threshold
cfg.utls.insertTableColumn(cfg.ui.signature_threshold_tableWidget, 7, cfg.tableColString, None, "Yes")
cfg.utls.setColumnWidthList(cfg.ui.signature_threshold_tableWidget, [[4, 100], [5, 100], [6, 100]])
try:
cfg.ui.signature_threshold_tableWidget.horizontalHeader().setResizeMode(1, cfg.QtGuiSCP.QHeaderView.Stretch)
cfg.ui.signature_threshold_tableWidget.horizontalHeader().setResizeMode(3, cfg.QtGuiSCP.QHeaderView.Stretch)
except:
pass
# band set list
cfg.utls.setColumnWidthList(cfg.ui.tableWidget, [[0, 350], [1, 150], [2, 150], [3, 150]])
# Landsat download tab
cfg.utls.setColumnWidthList(cfg.ui.landsat_images_tableWidget, [[0, 200]])
# Sentinel download tab
cfg.utls.setColumnWidthList(cfg.ui.sentinel_images_tableWidget, [[0, 300]])
# ASTER download tab
cfg.utls.setColumnWidthList(cfg.ui.aster_images_tableWidget, [[0, 300]])
# MODIS download tab
cfg.utls.setColumnWidthList(cfg.ui.modis_images_tableWidget, [[0, 300]])
# USGS spectral lbrary
cfg.usgsLib.addSpectralLibraryToCombo(cfg.usgs_lib_list)
cfg.usgs_C1p = cfg.plgnDir + "/spectralsignature/usgs_spectral_library/minerals.csv"
cfg.usgs_C2p = cfg.plgnDir + "/spectralsignature/usgs_spectral_library/mixtures.csv"
cfg.usgs_C3p = cfg.plgnDir + "/spectralsignature/usgs_spectral_library/coatings.csv"
cfg.usgs_C4p = cfg.plgnDir + "/spectralsignature/usgs_spectral_library/volatiles.csv"
cfg.usgs_C5p = cfg.plgnDir + "/spectralsignature/usgs_spectral_library/man-made.csv"
cfg.usgs_C6p = cfg.plgnDir + "/spectralsignature/usgs_spectral_library/plants_veg_microorg.csv"
# band calc expression
cfg.bCalc.createExpressionList(cfg.expressionListBC)
cfg.batchT.addFunctionsToCombo(cfg.functionNames)
cfg.bst.addSatelliteToCombo(cfg.satWlList)
cfg.downLandsat.addSatelliteToCombo(cfg.satLandsatList)
cfg.downASTER.addSatelliteToCombo(cfg.satASTERtList)
cfg.downMODIS.addSatelliteToCombo(cfg.satMODIStList)
cfg.scaPlT.addColormapToCombo(cfg.scatterColorMap)
cfg.bst.addUnitToCombo(cfg.unitList)
cfg.classD.previewSize()
# set log state
if cfg.logSetVal == "Yes":
cfg.ui.log_checkBox.setCheckState(2)
cfg.mx.msg19()
elif cfg.logSetVal == "No":
cfg.ui.log_checkBox.setCheckState(0)
# set download news state
if cfg.downNewsVal == "Yes":
cfg.ui.download_news_checkBox.setCheckState(2)
elif cfg.downNewsVal == "No":
cfg.ui.download_news_checkBox.setCheckState(0)
# set alg files state
if cfg.algFilesCheck == "Yes":
cfg.uidc.alg_files_checkBox.setCheckState(2)
elif cfg.algFilesCheck == "No":
cfg.uidc.alg_files_checkBox.setCheckState(0)
# set raster format
if cfg.outTempRastFormat == "VRT":
cfg.ui.virtual_raster_checkBox.setCheckState(2)
elif cfg.outTempRastFormat == "GTiff":
cfg.ui.virtual_raster_checkBox.setCheckState(0)
# set raster compression
if cfg.rasterCompression == "Yes":
cfg.ui.raster_compression_checkBox.setCheckState(2)
elif cfg.rasterCompression == "No":
cfg.ui.raster_compression_checkBox.setCheckState(0)
# set sound state
if cfg.soundVal == "Yes":
cfg.ui.sound_checkBox.setCheckState(2)
elif cfg.soundVal == "No":
cfg.ui.sound_checkBox.setCheckState(0)
# connect to project loaded
cfg.QObjectSCP.connect(cfg.qgisCoreSCP.QgsProject.instance(), cfg.SIGNALSCP("readProject(const QDomDocument &)"), self.projectLoaded)
cfg.QObjectSCP.connect(cfg.qgisCoreSCP.QgsProject.instance(), cfg.SIGNALSCP("projectSaved()"), self.projectSaved)
cfg.iface.newProjectCreated.connect(self.newProjectLoaded)
#cfg.QObjectSCP.connect(cfg.qgisCoreSCP.QgsProject.instance(), cfg.SIGNALSCP("loadingLayer(const QString &)"), self.test)
#cfg.qgisCoreSCP.QgsProject.instance().readMapLayer.connect(self.test)
#cfg.qgisCoreSCP.QgsProject.instance().layerLoaded.connect(self.test)
""" Docks """
# reload layers in combos
cfg.ipt.refreshRasterLayer()
cfg.utls.refreshVectorLayer()
# set ROI color
cfg.ui.change_color_Button.setStyleSheet("background-color :" + cfg.ROIClrVal)
# set ROI transparency
cfg.ui.transparency_Slider.setValue(cfg.ROITrnspVal)
# set RAM value
cfg.ui.RAM_spinBox.setValue(cfg.RAMValue)
# macroclass checkbox
if cfg.macroclassCheck == "No":
cfg.uidc.macroclass_checkBox.setCheckState(0)
cfg.uidc.class_checkBox.blockSignals(True)
cfg.uidc.class_checkBox.setCheckState(2)
cfg.uidc.class_checkBox.blockSignals(False)
elif cfg.macroclassCheck == "Yes":
cfg.uidc.macroclass_checkBox.setCheckState(2)
cfg.uidc.class_checkBox.blockSignals(True)
cfg.uidc.class_checkBox.setCheckState(0)
cfg.uidc.class_checkBox.blockSignals(False)
# LC signature checkbox
if cfg.LCsignatureCheckBox == "No":
cfg.uidc.LC_signature_checkBox.setCheckState(0)
elif cfg.LCsignatureCheckBox == "Yes":
cfg.uidc.LC_signature_checkBox.setCheckState(2)
try:
# set ID field name line
cfg.ui.ID_field_name_lineEdit.setText(cfg.fldID_class)
cfg.ui.MID_field_name_lineEdit.setText(cfg.fldMacroID_class)
# set Info field name line
cfg.ui.Info_field_name_lineEdit.setText(cfg.fldROI_info)
cfg.ui.MCInfo_field_name_lineEdit.setText(cfg.fldROIMC_info)
cfg.ui.variable_name_lineEdit.setText(cfg.variableName)
cfg.ui.group_name_lineEdit.setText(cfg.grpNm)
# set USGS user and password
cfg.ui.user_usgs_lineEdit.setText(cfg.USGSUser)
USGSPsw = cfg.utls.decryptPassword(cfg.USGSPass)
cfg.ui.password_usgs_lineEdit.setText(USGSPsw)
cfg.ui.user_usgs_lineEdit_2.setText(cfg.USGSUserASTER)
cfg.ui.user_usgs_lineEdit_3.setText(cfg.USGSUserMODIS)
USGSPsw2 = cfg.utls.decryptPassword(cfg.USGSPassASTER)
cfg.ui.password_usgs_lineEdit_2.setText(USGSPsw2)
USGSPsw3 = cfg.utls.decryptPassword(cfg.USGSPassMODIS)
cfg.ui.password_usgs_lineEdit_3.setText(USGSPsw3)
# set SciHub user and password
cfg.ui.sentinel_service_lineEdit.setText(cfg.SciHubService)
cfg.ui.user_scihub_lineEdit.setText(cfg.SciHubUser)
sciHubPsw = cfg.utls.decryptPassword(cfg.SciHubPass)
cfg.ui.password_scihub_lineEdit.setText(sciHubPsw)
except Exception, err:
# logger
cfg.utls.logCondition(str(__name__) + "-" + (cfg.inspectSCP.stack()[0][3])+ " " + cfg.utls.lineOfCode(), " ERROR exception: " + str(err))
# reload layers in combos
cfg.utls.refreshClassificationLayer()
cfg.utls.refreshRasterExtent()
cfg.acc.refreshReferenceLayer()
cfg.crossC.refreshReferenceLayer()
cfg.landCC.refreshClassificationReferenceLayer()
cfg.landCC.refreshNewClassificationLayer()
# reload raster bands in checklist
cfg.bst.rasterBandName()
# reload rasters in checklist
cfg.clipMulti.rasterNameList()
cfg.stackRstr.rasterNameList()
""" Multiple ROI tab """
# connect to add point
cfg.ui.add_point_pushButton.clicked.connect(cfg.multiROI.addPointToTable)
# connect to create random points
cfg.ui.add_random_point_pushButton.clicked.connect(cfg.multiROI.createRandomPoint)
# connect to remove point
cfg.ui.remove_point_pushButton.clicked.connect(cfg.multiROI.removePointFromTable)
# connect to save point ROIs
cfg.ui.save_point_rois_pushButton.clicked.connect(cfg.multiROI.createROIfromPoint)
# connect to import points
cfg.ui.import_point_list_pushButton.clicked.connect(cfg.multiROI.importPoints)
# connect to export point list
cfg.ui.export_point_list_pushButton.clicked.connect(cfg.multiROI.exportPointList)
# connect the signature calculation checkBox 2
cfg.ui.signature_checkBox2.stateChanged.connect(cfg.multiROI.signatureCheckbox2)
""" Import spectral signature tab """
# connect the import library
cfg.ui.open_library_pushButton.clicked.connect(cfg.classD.openLibraryFile)
# connect the open shapefile
cfg.ui.open_shapefile_pushButton.clicked.connect(cfg.sigImport.openShapefileI)
# connect the import shapefile
cfg.ui.import_shapefile_pushButton.clicked.connect(cfg.utls.importShapefile)
# connect the chapter changed
cfg.ui.usgs_chapter_comboBox.currentIndexChanged.connect(cfg.usgsLib.chapterChanged)
# connect the library changed
cfg.ui.usgs_library_comboBox.currentIndexChanged.connect(cfg.usgsLib.libraryChanged)
# connect the close library
cfg.ui.add_usgs_library_pushButton.clicked.connect(cfg.usgsLib.addSignatureToList)
""" Export spectral signature tab """
# connect to export signature to SCP file
cfg.ui.export_SCP_pushButton.clicked.connect(cfg.classD.exportSignatureFile)
cfg.ui.export_SHP_pushButton.clicked.connect(cfg.classD.exportSignatureShapefile)
# connect to export signature to CSV
cfg.ui.export_CSV_library_toolButton.clicked.connect(cfg.classD.exportToCSVLibrary)
""" Algorithm weight tab """
# edited cell
cfg.ui.tableWidget_weight.cellChanged.connect(cfg.algWT.editedWeightTable)
cfg.ui.reset_weights_pushButton.clicked.connect(cfg.algWT.resetWeights)
cfg.ui.set_weight_value_pushButton.clicked.connect(cfg.algWT.setWeights)
""" Signature threshold tab """
# edited cell
cfg.ui.signature_threshold_tableWidget.cellChanged.connect(cfg.signT.editedThresholdTable)
cfg.ui.reset_threshold_pushButton.clicked.connect(cfg.signT.resetThresholds)
cfg.ui.automatic_threshold_pushButton.clicked.connect(cfg.signT.setAllWeightsVariance)
cfg.ui.set_threshold_value_pushButton.clicked.connect(cfg.signT.setThresholds)
cfg.ui.signature_threshold_tableWidget.horizontalHeader().sectionClicked.connect(cfg.signT.orderedTable)
""" LC Signature threshold tab """
cfg.ui.LCS_tableWidget.cellChanged.connect(cfg.LCSignT.editedThresholdTable)
cfg.ui.LCS_tableWidget.horizontalHeader().sectionClicked.connect(cfg.LCSignT.orderedTable)
cfg.ui.automatic_threshold_pushButton_2.clicked.connect(cfg.LCSignT.setAllWeightsVariance)
# connect to activate pointer
cfg.ui.LCS_pointerButton.clicked.connect(cfg.LCSignT.pointerActive)
cfg.ui.LCS_ROI_button.clicked.connect(cfg.LCSignT.ROIThreshold)
cfg.ui.set_min_max_Button.clicked.connect(cfg.LCSignT.setMinimumMaximum)
# connect the include signature checkBox
cfg.ui.LCS_include_checkBox.stateChanged.connect(cfg.LCSignT.includeCheckbox)
cfg.ui.LCS_cut_checkBox.stateChanged.connect(cfg.LCSignT.cutCheckbox)
# add to spectral signature plot
cfg.ui.signature_spectral_plot_toolButton_2.clicked.connect(cfg.LCSignT.addSignatureToSpectralPlot)
""" RGB List tab """
cfg.ui.RGB_tableWidget.cellChanged.connect(cfg.RGBLT.editedTable)
cfg.ui.add_RGB_pushButton.clicked.connect(cfg.RGBLT.addRGBToTable)
cfg.ui.remove_RGB_toolButton.clicked.connect(cfg.RGBLT.removeRGBFromTable)
cfg.ui.sort_by_name_toolButton_2.clicked.connect(cfg.RGBLT.sortRGBName)
cfg.ui.clear_RGB_list_toolButton.clicked.connect(cfg.RGBLT.clearTableAction)
cfg.ui.move_up_toolButton_3.clicked.connect(cfg.RGBLT.moveUpRGB)
cfg.ui.move_down_toolButton_3.clicked.connect(cfg.RGBLT.moveDownRGB)
cfg.ui.all_RGB_list_toolButton.clicked.connect(cfg.RGBLT.allRGBListAction)
cfg.ui.export_RGB_List_toolButton.clicked.connect(cfg.RGBLT.exportRGBList)
cfg.ui.import_RGB_List_toolButton.clicked.connect(cfg.RGBLT.importRGB)
""" Download Landsat tab """
# connect to find images button
cfg.ui.find_images_toolButton.clicked.connect(cfg.downLandsat.findImages)
cfg.ui.selectUL_toolButton_3.clicked.connect(cfg.downLandsat.pointerActive)
# connect to display button
cfg.ui.toolButton_display.clicked.connect(cfg.downLandsat.displayImages)
cfg.ui.remove_image_toolButton.clicked.connect(cfg.downLandsat.removeImageFromTable)
cfg.ui.clear_table_toolButton.clicked.connect(cfg.downLandsat.clearTable)
cfg.ui.download_images_Button.clicked.connect(cfg.downLandsat.downloadImages)
cfg.ui.export_links_Button.clicked.connect(cfg.downLandsat.exportLinks)
cfg.ui.check_toolButton.clicked.connect(cfg.downLandsat.checkAllBands)
cfg.ui.show_area_radioButton_2.clicked.connect(cfg.downLandsat.showHideArea)
cfg.ui.remember_user_checkBox_2.stateChanged.connect(cfg.downLandsat.rememberUserCheckbox)
cfg.ui.user_usgs_lineEdit.editingFinished.connect(cfg.downLandsat.rememberUser)
cfg.ui.password_usgs_lineEdit.editingFinished.connect(cfg.downLandsat.rememberUser)
""" Download Sentinel tab """
# connect to find images button
cfg.ui.reset_sentinel_service_toolButton.clicked.connect(cfg.downSentinel.resetService)
cfg.ui.find_images_toolButton_3.clicked.connect(cfg.downSentinel.findImages)
cfg.ui.selectUL_toolButton_5.clicked.connect(cfg.downSentinel.pointerActive)
cfg.ui.clear_table_toolButton_3.clicked.connect(cfg.downSentinel.clearTable)
cfg.ui.export_links_Button_3.clicked.connect(cfg.downSentinel.exportLinks)
cfg.ui.toolButton_display_3.clicked.connect(cfg.downSentinel.displayImages)
cfg.ui.toolButton_granule_preview.clicked.connect(cfg.downSentinel.displayGranules)
cfg.ui.check_toolButton_2.clicked.connect(cfg.downSentinel.checkAllBands)
cfg.ui.sentinel_service_lineEdit.editingFinished.connect(cfg.downSentinel.rememberService)
cfg.ui.user_scihub_lineEdit.editingFinished.connect(cfg.downSentinel.rememberUser)
cfg.ui.password_scihub_lineEdit.editingFinished.connect(cfg.downSentinel.rememberUser)
cfg.ui.remember_user_checkBox.stateChanged.connect(cfg.downSentinel.rememberUserCheckbox)
cfg.ui.download_images_Button_3.clicked.connect(cfg.downSentinel.downloadImages)
cfg.ui.remove_image_toolButton_3.clicked.connect(cfg.downSentinel.removeImageFromTable)
cfg.ui.show_area_radioButton.clicked.connect(cfg.downSentinel.showHideArea)
""" Download ASTER tab """
# connect to find images button
cfg.ui.find_images_toolButton_2.clicked.connect(cfg.downASTER.findImages)
cfg.ui.selectUL_toolButton_4.clicked.connect(cfg.downASTER.pointerActive)
# connect to display button
cfg.ui.toolButton_display_2.clicked.connect(cfg.downASTER.displayImages)
cfg.ui.remove_image_toolButton_2.clicked.connect(cfg.downASTER.removeImageFromTable)
cfg.ui.clear_table_toolButton_2.clicked.connect(cfg.downASTER.clearTable)
cfg.ui.download_images_Button_2.clicked.connect(cfg.downASTER.downloadImages)
cfg.ui.export_links_Button_2.clicked.connect(cfg.downASTER.exportLinks)
cfg.ui.show_area_radioButton_4.clicked.connect(cfg.downASTER.showHideArea)
cfg.ui.remember_user_checkBox_3.stateChanged.connect(cfg.downASTER.rememberUserCheckbox)
cfg.ui.user_usgs_lineEdit_2.editingFinished.connect(cfg.downASTER.rememberUser)
cfg.ui.password_usgs_lineEdit_2.editingFinished.connect(cfg.downASTER.rememberUser)
""" Download MODIS tab """
# connect to find images button
cfg.ui.find_images_toolButton_4.clicked.connect(cfg.downMODIS.findImages)
cfg.ui.selectUL_toolButton_6.clicked.connect(cfg.downMODIS.pointerActive)
# connect to display button
cfg.ui.toolButton_display_4.clicked.connect(cfg.downMODIS.displayImages)
cfg.ui.remove_image_toolButton_4.clicked.connect(cfg.downMODIS.removeImageFromTable)
cfg.ui.clear_table_toolButton_4.clicked.connect(cfg.downMODIS.clearTable)
cfg.ui.download_images_Button_4.clicked.connect(cfg.downMODIS.downloadImages)
cfg.ui.export_links_Button_4.clicked.connect(cfg.downMODIS.exportLinks)
cfg.ui.show_area_radioButton_5.clicked.connect(cfg.downMODIS.showHideArea)
cfg.ui.remember_user_checkBox_4.stateChanged.connect(cfg.downMODIS.rememberUserCheckbox)
cfg.ui.user_usgs_lineEdit_3.editingFinished.connect(cfg.downMODIS.rememberUser)
cfg.ui.password_usgs_lineEdit_3.editingFinished.connect(cfg.downMODIS.rememberUser)
""" Classification dock """
# combo layer
cfg.uidc.raster_name_combo.currentIndexChanged.connect(cfg.ipt.rasterLayerName)
# button reload
cfg.uidc.toolButton_reload.clicked.connect(cfg.ipt.checkRefreshRasterLayer)
# button band set
cfg.uidc.bandset_toolButton.clicked.connect(cfg.utls.bandSetTab)
cfg.uidc.input_raster_toolButton.clicked.connect(cfg.bst.addFileToBandSetAction)
cfg.uidc.ROItools_toolButton_2.clicked.connect(cfg.utls.roiToolsTab)
cfg.uidc.preprocessing_toolButton_2.clicked.connect(cfg.utls.preProcessingTab)
cfg.uidc.postprocessing_toolButton_2.clicked.connect(cfg.utls.postProcessingTab)
cfg.uidc.bandcalc_toolButton_2.clicked.connect(cfg.utls.bandCalcTab)
cfg.uidc.download_images_toolButton_2.clicked.connect(cfg.utls.selectTabDownloadImages)
cfg.uidc.settings_toolButton_2.clicked.connect(cfg.utls.settingsTab)
cfg.uidc.userguide_toolButton_2.clicked.connect(cfg.ipt.quickGuide)
cfg.uidc.help_toolButton_2.clicked.connect(cfg.ipt.askHelp)
# button new shapefile
cfg.uidc.button_new_input.clicked.connect(cfg.classD.createInput)
# connect to save to shapefile
cfg.uidc.button_Save_ROI.clicked.connect(cfg.classD.saveROItoShapefile)
# connect to undo save ROI
cfg.uidc.undo_save_Button.clicked.connect(cfg.classD.undoSaveROI)
# connect the signature calculation checkBox
cfg.uidc.signature_checkBox.stateChanged.connect(cfg.classD.signatureCheckbox)
cfg.uidc.scatterPlot_toolButton.clicked.connect(cfg.classD.addROIToScatterPlot)
# connect to open training shapefile
cfg.uidc.trainingFile_toolButton.clicked.connect(cfg.classD.openTrainingFile)
# connect to export signature list file
cfg.uidc.export_signature_list_toolButton.clicked.connect(cfg.utls.exportLibraryTab)
# connect to import library file
cfg.uidc.import_library_toolButton.clicked.connect(cfg.utls.importLibraryTab)
# add to spectral signature plot
cfg.uidc.signature_spectral_plot_toolButton.clicked.connect(cfg.classD.addSignatureToSpectralPlot)
# connect to edited cell
cfg.uidc.signature_list_tableWidget.cellChanged.connect(cfg.classD.editedCell)
# connect to signature list double click
cfg.uidc.signature_list_tableWidget.doubleClicked.connect(cfg.classD.signatureListDoubleClick)
# connect to delete signature
cfg.uidc.delete_Signature_Button.clicked.connect(cfg.classD.removeSelectedSignatures)
# connect to merge signatures
cfg.uidc.merge_signature_toolButton.clicked.connect(cfg.classD.mergeSelectedSignatures)
cfg.uidc.calculate_signature_toolButton.clicked.connect(cfg.classD.calculateSignatures)
# connect the ROI macroclass ID
cfg.uidc.ROI_Macroclass_ID_spin.valueChanged.connect(cfg.classD.setROIMacroID)
# connect the ROI Macroclass
cfg.uidc.ROI_Macroclass_line.editingFinished.connect(cfg.classD.roiMacroclassInfo)
# custom expression
cfg.uidc.custom_index_lineEdit.editingFinished.connect(cfg.classD.customExpressionEdited)
# connect the ROI Class ID
cfg.uidc.ROI_ID_spin.valueChanged.connect(cfg.classD.setROIID)
# connect the ROI Class
cfg.uidc.ROI_Class_line.editingFinished.connect(cfg.classD.roiClassInfo)
# connect the rapid ROI checkBox
cfg.uidc.display_cursor_checkBox.stateChanged.connect(cfg.classD.vegetationIndexCheckbox)
# connect the vegetation index combo
cfg.uidc.vegetation_index_comboBox.currentIndexChanged.connect(cfg.classD.vegetationIndexName)
# connect the rapid ROI checkBox
cfg.uidc.rapid_ROI_checkBox.stateChanged.connect(cfg.classD.rapidROICheckbox)
# connect the vegetation index display checkbox
cfg.uidc.rapidROI_band_spinBox.valueChanged.connect(cfg.classD.rapidROIband)
# connect to algorithm weight button
cfg.uidc.algorithm_weight_button.clicked.connect(cfg.utls.algorithmWeighTab)
# connect to threshold button
cfg.uidc.algorithm_threshold_button.clicked.connect(cfg.utls.algorithmThresholdTab)
# connect to LCS threshold button
cfg.uidc.LC_signature_button.clicked.connect(cfg.utls.LCSThresholdTab)
# connect the algorithm combo
cfg.uidc.algorithm_combo.currentIndexChanged.connect(cfg.classD.algorithmName)
# connect the algorithm threshold
cfg.uidc.alg_threshold_SpinBox.valueChanged.connect(cfg.classD.algorithmThreshold)
# connect to edited cell
cfg.uidc.macroclass_color_tableWidget.cellChanged.connect(cfg.classD.McIdEditedCell)
# connect to MC ID double click
cfg.uidc.macroclass_color_tableWidget.doubleClicked.connect(cfg.classD.McIdDoubleClick)
# connect to add row
cfg.uidc.add_MC_row_Button.clicked.connect(cfg.classD.addMCIDToTable)
cfg.uidc.delete_MC_row_Button.clicked.connect(cfg.classD.removeMCIDFromTable)
# connect to run classification
cfg.uidc.button_classification.clicked.connect(cfg.classD.runClassificationAction)
# connect the alg files checkBox
cfg.uidc.alg_files_checkBox.stateChanged.connect(cfg.sets.algFilesCheckbox)
# connect the vector output checkBox
cfg.uidc.vector_output_checkBox.stateChanged.connect(cfg.classD.vectorCheckbox)
# connect the macroclass checkBox
cfg.uidc.macroclass_checkBox.stateChanged.connect(cfg.classD.macroclassCheckbox)
cfg.uidc.class_checkBox.stateChanged.connect(cfg.classD.classCheckbox)
# connect the LC signature checkBox
cfg.uidc.LC_signature_checkBox.stateChanged.connect(cfg.classD.LCSignature_Checkbox)
# connect the report checkBox
cfg.uidc.report_checkBox.stateChanged.connect(cfg.classD.reportCheckbox)
# connect the mask checkBox
cfg.uidc.mask_checkBox.stateChanged.connect(cfg.classD.maskCheckbox)
# connect to reset qml button
cfg.uidc.resetQmlButton.clicked.connect(cfg.classD.resetQmlStyle)
# connect to reset mask button
cfg.uidc.resetMaskButton.clicked.connect(cfg.classD.resetMask)
""" Spectral signature plot """
# connect the sigma checkBox
cfg.uisp.sigma_checkBox.stateChanged.connect(cfg.spSigPlot.sigmaCheckbox)
cfg.uisp.band_lines_checkBox.stateChanged.connect(cfg.spSigPlot.refreshPlot)
cfg.uisp.grid_checkBox.stateChanged.connect(cfg.spSigPlot.refreshPlot)
# connect to remove signature button
cfg.uisp.remove_Signature_Button.clicked.connect(cfg.spSigPlot.removeSignature)
# connect to calculate spectral distances button
cfg.uisp.calculate_spectral_distance_Button.clicked.connect(cfg.spSigPlot.calculateSpectralDistances)
# connect to fit to axes
cfg.uisp.fitToAxes_pushButton.clicked.connect(cfg.spSigPlot.fitPlotToAxes)
# connect to plot spinbox
cfg.uisp.plot_text_spinBox.valueChanged.connect(cfg.spSigPlot.setPlotLegendLenght)
# connect to value range
cfg.uisp.value_range_pushButton.clicked.connect(cfg.spSigPlot.editValueRange)
cfg.uisp.set_min_max_Button.clicked.connect(cfg.spSigPlot.setMinimumMaximum)
cfg.uisp.automatic_threshold_pushButton_2.clicked.connect(cfg.spSigPlot.setAllWeightsVariance)
# connect to activate pointer
cfg.uisp.LCS_pointerButton_2.clicked.connect(cfg.spSigPlot.pointerActive)
cfg.uisp.LCS_ROI_button_2.clicked.connect(cfg.spSigPlot.ROIThreshold)
# undo threshold
cfg.uisp.undo_threshold_Button.clicked.connect(cfg.spSigPlot.undoThreshold)
# connect the include signature checkBox
cfg.uisp.LCS_include_checkBox_2.stateChanged.connect(cfg.spSigPlot.includeCheckbox)
cfg.uisp.LCS_cut_checkBox_2.stateChanged.connect(cfg.spSigPlot.cutCheckbox)
# connect to add to signature list
cfg.uisp.add_signature_list_pushButton.clicked.connect(cfg.spSigPlot.addToSignatureList)
# connect to save plot
cfg.uisp.save_plot_pushButton.clicked.connect(cfg.spSigPlot.savePlot)
# connect to edited cell
cfg.uisp.signature_list_plot_tableWidget.cellChanged.connect(cfg.spSigPlot.editedCell)
cfg.uisp.signature_list_plot_tableWidget.horizontalHeader().sectionClicked.connect(cfg.spSigPlot.orderedTable)
# connect to signature plot list double click
cfg.uisp.signature_list_plot_tableWidget.doubleClicked.connect(cfg.spSigPlot.signatureListDoubleClick)
""" Scatter plot tab """
# connect to scatter plot button
cfg.uiscp.scatter_ROI_Button.clicked.connect(cfg.scaPlT.scatterPlotCalc)
# connect to Band X spinbox
cfg.uiscp.bandX_spinBox.valueChanged.connect(cfg.scaPlT.bandXPlot)
# connect to Band Y spinbox
cfg.uiscp.bandY_spinBox.valueChanged.connect(cfg.scaPlT.bandYPlot)
# connect double click ROI list to zoom
cfg.uiscp.scatter_list_plot_tableWidget.doubleClicked.connect(cfg.scaPlT.scatterPlotDoubleClick)
# connect to edited cell
cfg.uiscp.scatter_list_plot_tableWidget.cellChanged.connect(cfg.scaPlT.editedCell)
# connect to remove signature button
cfg.uiscp.remove_Signature_Button.clicked.connect(cfg.scaPlT.removeScatter)
# connect to save plot
cfg.uiscp.save_plot_pushButton_2.clicked.connect(cfg.scaPlT.savePlot)
# connect to fit to axes
cfg.uiscp.fitToAxes_pushButton_2.clicked.connect(cfg.scaPlT.fitPlotToAxes)
cfg.uiscp.plot_temp_ROI_pushButton.clicked.connect(cfg.scaPlT.addTempROIToScatterPlot)
cfg.uiscp.plot_display_pushButton.clicked.connect(cfg.scaPlT.addDisplayToScatterPlot)
cfg.uiscp.plot_image_pushButton.clicked.connect(cfg.scaPlT.addImageToScatterPlot)
# connect to change color button
cfg.uiscp.polygon_color_Button.clicked.connect(cfg.scaPlT.changePolygonColor)
cfg.uiscp.plot_color_ROI_pushButton.clicked.connect(cfg.scaPlT.colorPlot)
# connect to select value range
cfg.uiscp.draw_polygons_pushButton.clicked.connect(cfg.scaPlT.selectRange)
cfg.uiscp.remove_polygons_pushButton.clicked.connect(cfg.scaPlT.removePolygons)
cfg.uiscp.show_polygon_area_pushButton.clicked.connect(cfg.scaPlT.showScatterPolygonArea)
cfg.uiscp.add_signature_list_pushButton.clicked.connect(cfg.scaPlT.addToSignatureList)
""" Band set tab """
# edited cell
cfg.ui.tableWidget.cellChanged.connect(cfg.bst.editedBandSet)
# connect to refresh button
cfg.ui.toolButton_reload_3.clicked.connect(cfg.bst.rasterBandName)
# connect to add file button
cfg.ui.toolButton_input_raster.clicked.connect(cfg.bst.addFileToBandSetAction)
# connect to add raster band button
cfg.ui.add_raster_bands_Button.clicked.connect(cfg.bst.addBandToSet)
# connect to select all bands button
cfg.ui.select_all_bands_Button.clicked.connect(cfg.bst.selectAllBands)
# connect to clear band set button
cfg.ui.clear_bandset_toolButton.clicked.connect(cfg.bst.clearBandSetAction)
# connect to move up band button
cfg.ui.move_up_toolButton.clicked.connect(cfg.bst.moveUpBand)
# connect to move down band button
cfg.ui.move_down_toolButton.clicked.connect(cfg.bst.moveDownBand)
# connect to sort by name button
cfg.ui.sort_by_name_toolButton.clicked.connect(cfg.bst.sortBandName)
# connect to remove band button
cfg.ui.remove_toolButton.clicked.connect(cfg.bst.removeBand)
# connect to import band set button
cfg.ui.import_bandset_toolButton.clicked.connect(cfg.bst.importBandSet)
# connect to export band set button
cfg.ui.export_bandset_toolButton.clicked.connect(cfg.bst.exportBandSet)
# connect to satellite wavelength combo
cfg.ui.wavelength_sat_combo.currentIndexChanged.connect(cfg.bst.satelliteWavelength)
# connect to unit combo
cfg.ui.unit_combo.currentIndexChanged.connect(cfg.bst.setBandUnit)
# connect to band set processs button
cfg.ui.band_set_process_toolButton.clicked.connect(cfg.bst.performBandSetTools)
""" Pre processing tab """
""" Clip multiple rasters """
# connect to clip button
cfg.ui.clip_Button.clicked.connect(cfg.clipMulti.clipRastersAction)
# connect to refresh rasters button
cfg.ui.toolButton_reload_7.clicked.connect(cfg.clipMulti.rasterNameList)
# connect to select all rasters button
cfg.ui.select_all_rasters_Button_2.clicked.connect(cfg.clipMulti.selectAllRasters)
# connect to activate UL pointer
cfg.ui.selectUL_toolButton.clicked.connect(cfg.clipMulti.pointerActive)
# connect to refresh shape button
cfg.ui.toolButton_reload_8.clicked.connect(cfg.clipMulti.refreshShapeClip)
cfg.ui.show_area_radioButton_3.clicked.connect(cfg.clipMulti.showHideArea)
cfg.ui.shapefile_checkBox.stateChanged.connect(cfg.clipMulti.checkboxShapeChanged)
cfg.ui.temporary_ROI_checkBox.stateChanged.connect(cfg.clipMulti.checkboxTempROIChanged)
""" Stack raster bands """
# connect to stack button
cfg.ui.stack_Button.clicked.connect(cfg.stackRstr.stackAction)
# connect to refresh rasters button
cfg.ui.toolButton_reload_22.clicked.connect(cfg.stackRstr.rasterNameList)
# connect to select all rasters button
cfg.ui.select_all_rasters_Button_3.clicked.connect(cfg.stackRstr.selectAllRasters)
""" ASTER tab """
# connect to input button
cfg.ui.toolButton_directoryInput_ASTER.clicked.connect(cfg.ASTERT.inputASTER)
cfg.ui.ASTER_tableWidget.cellChanged.connect(cfg.ASTERT.editedCell)
cfg.ui.earth_sun_dist_lineEdit_2.textChanged.connect(cfg.ASTERT.editedEarthSunDist)
cfg.ui.sun_elev_lineEdit_2.textChanged.connect(cfg.ASTERT.editedSunElevation)
cfg.ui.date_lineEdit_2.textChanged.connect(cfg.ASTERT.editedDate)
cfg.ui.pushButton_Conversion_3.clicked.connect(cfg.ASTERT.performASTERCorrection)
cfg.ui.pushButton_remove_band_2.clicked.connect(cfg.ASTERT.removeHighlightedBand)
""" MODIS tab """
# connect to input button
cfg.ui.toolButton_directoryInput_MODIS.clicked.connect(cfg.MODIST.inputMODIS)
cfg.ui.MODIS_tableWidget.cellChanged.connect(cfg.MODIST.editedCell)
cfg.ui.pushButton_Conversion_4.clicked.connect(cfg.MODIST.performMODISConversion)
cfg.ui.pushButton_remove_band_3.clicked.connect(cfg.MODIST.removeHighlightedBand)
""" Landsat tab """
# connect to input button
cfg.ui.toolButton_directoryInput.clicked.connect(cfg.landsatT.inputLandsat)
cfg.ui.toolButton_directoryInput_MTL.clicked.connect(cfg.landsatT.inputMTL)
cfg.ui.pushButton_Conversion.clicked.connect(cfg.landsatT.performLandsatCorrection)
cfg.ui.pushButton_remove_band.clicked.connect(cfg.landsatT.removeHighlightedBand)
cfg.ui.landsat_tableWidget.cellChanged.connect(cfg.landsatT.editedCell)
cfg.ui.earth_sun_dist_lineEdit.textChanged.connect(cfg.landsatT.editedEarthSunDist)
cfg.ui.sun_elev_lineEdit.textChanged.connect(cfg.landsatT.editedSunElevation)
cfg.ui.date_lineEdit.textChanged.connect(cfg.landsatT.editedDate)
cfg.ui.satellite_lineEdit.textChanged.connect(cfg.landsatT.editedSatellite)
""" Sentinel-2 tab """
# connect to input button
cfg.ui.S2_toolButton_directoryInput.clicked.connect(cfg.sentinel2T.inputSentinel)
cfg.ui.pushButton_Conversion_2.clicked.connect(cfg.sentinel2T.performSentinelConversion)
cfg.ui.S2_satellite_lineEdit.textChanged.connect(cfg.sentinel2T.editedSatellite)
cfg.ui.S2_pushButton_remove_band.clicked.connect(cfg.sentinel2T.removeHighlightedBand)
cfg.ui.sentinel_2_tableWidget.cellChanged.connect(cfg.sentinel2T.editedCell)
cfg.ui.S2_toolButton_directoryInput_xml2.clicked.connect(cfg.sentinel2T.inputXML2)
""" Split tab """
# connect the classification combo
cfg.ui.raster_name_combo.currentIndexChanged.connect(cfg.splitT.rasterLayerName)
# connect to refresh button
cfg.ui.toolButton_reload_9.clicked.connect(cfg.splitT.refreshClassificationLayer)
# connect to split raster button
cfg.ui.split_Button.clicked.connect(cfg.splitT.splitRaster)
""" PCA tab """
# connect to PCA button
cfg.ui.pca_Button.clicked.connect(cfg.pcaT.calculatePCAAction)
""" Vector to Raster tab """
cfg.ui.toolButton_reload_16.clicked.connect(cfg.vctRstrT.reloadVectorList)
cfg.ui.toolButton_reload_17.clicked.connect(cfg.utls.refreshClassificationLayer)
cfg.ui.convert_vector_toolButton.clicked.connect(cfg.vctRstrT.convertToRasterAction)
cfg.ui.vector_name_combo.currentIndexChanged.connect(cfg.utls.refreshVectorFields)
cfg.ui.field_checkBox.stateChanged.connect(cfg.vctRstrT.checkboxFieldChanged)
cfg.ui.constant_value_checkBox.stateChanged.connect(cfg.vctRstrT.checkboxConstantValueChanged)
""" Post processing tab """
""" accuracy tab """
# connect the classification combo
cfg.ui.classification_name_combo.currentIndexChanged.connect(cfg.acc.classificationLayerName)
# connect to refresh button
cfg.ui.toolButton_reload_4.clicked.connect(cfg.utls.refreshClassificationLayer)
# connect the reference combo
cfg.ui.reference_name_combo.currentIndexChanged.connect(cfg.acc.referenceLayerName)