@@ -270,8 +270,8 @@ def process_data2(self):
270270 QMessageBox .critical (self , "Error" , "Please select the working directory!" )
271271 return
272272
273- if not self .in_fn :
274- QMessageBox .critical (self , "Error" , "Please select the input file !" )
273+ if not self .in_fn or not self . mask :
274+ QMessageBox .critical (self , "Error" , "Please select all input files !" )
275275 return
276276
277277 NRT = self .nrt_entry .text ()
@@ -329,7 +329,7 @@ def process_data2(self):
329329
330330 try :
331331 self .vulnerability_map .set_working_directory (directory )
332- mask_arr = self .vulnerability_map .geometric_classification (self .in_fn , NRT , n_classes )
332+ mask_arr = self .vulnerability_map .geometric_classification (self .in_fn , NRT , n_classes , self . mask )
333333 self .vulnerability_map .array_to_image (self .in_fn , out_fn , mask_arr , gdal .GDT_Int16 , - 1 )
334334 self .vulnerability_map .replace_ref_system (self .in_fn , out_fn )
335335
@@ -828,6 +828,7 @@ def __init__(self):
828828 self .doc_button = self .tab1 .findChild (QWidget , "doc_button" )
829829 self .select_folder_button = self .tab1 .findChild (QWidget , "select_folder_button" )
830830 self .fd_button = self .tab1 .findChild (QWidget , "fd_button" )
831+ self .mask_button = self .tab1 .findChild (QWidget , "mask_button" )
831832 self .ok_button2 = self .tab1 .findChild (QWidget , "ok_button2" )
832833
833834 self .doc_button_2 = self .tab2 .findChild (QWidget , "doc_button_2" )
@@ -840,6 +841,7 @@ def __init__(self):
840841 self .doc_button .clicked .connect (self .openDocument )
841842 self .select_folder_button .clicked .connect (self .select_working_directory )
842843 self .fd_button .clicked .connect (self .select_fd )
844+ self .mask_button .clicked .connect (self .select_mask )
843845 self .ok_button2 .clicked .connect (self .process_data2 )
844846
845847 self .doc_button_2 .clicked .connect (self .openDocument_2 )
@@ -854,6 +856,7 @@ def __init__(self):
854856 self .directory = None
855857 self .in_fn = None
856858 self .NRT = None
859+ self .mask = None
857860 # Use NRT from the data store
858861 if central_data_store .NRT is not None :
859862 self .nrt_entry .setText (str (central_data_store .NRT ))
@@ -910,6 +913,11 @@ def select_fd(self):
910913 if file_path :
911914 self .in_fn = file_path
912915 self .in_fn_entry .setText (file_path .split ('/' )[- 1 ])
916+ def select_mask (self ):
917+ file_path , _ = QFileDialog .getOpenFileName (self , 'Mask of Study Area' )
918+ if file_path :
919+ self .mask = file_path
920+ self .mask_entry .setText (file_path .split ('/' )[- 1 ])
913921
914922 def select_working_directory_2 (self ):
915923 data_folder_2 = QFileDialog .getExistingDirectory (self , "Working Directory" )
@@ -943,8 +951,8 @@ def process_data2(self):
943951 QMessageBox .critical (self , "Error" , "Please select the working directory!" )
944952 return
945953
946- if not self .in_fn :
947- QMessageBox .critical (self , "Error" , "Please select the input file !" )
954+ if not self .in_fn or not self . mask :
955+ QMessageBox .critical (self , "Error" , "Please select all input files !" )
948956 return
949957
950958 NRT = self .nrt_entry .text ()
@@ -1001,7 +1009,7 @@ def process_data2(self):
10011009
10021010 try :
10031011 self .vulnerability_map .set_working_directory (directory )
1004- mask_arr = self .vulnerability_map .geometric_classification (self .in_fn , NRT , n_classes )
1012+ mask_arr = self .vulnerability_map .geometric_classification (self .in_fn , NRT , n_classes , self . mask )
10051013 self .vulnerability_map .array_to_image (self .in_fn , out_fn , mask_arr , gdal .GDT_Int16 , - 1 )
10061014 self .vulnerability_map .replace_ref_system (self .in_fn , out_fn )
10071015
@@ -1553,6 +1561,7 @@ def __init__(self):
15531561 self .doc_button = self .tab1 .findChild (QWidget , "doc_button" )
15541562 self .select_folder_button = self .tab1 .findChild (QWidget , "select_folder_button" )
15551563 self .fd_button = self .tab1 .findChild (QWidget , "fd_button" )
1564+ self .mask_button = self .tab1 .findChild (QWidget , "mask_button" )
15561565 self .ok_button2 = self .tab1 .findChild (QWidget , "ok_button2" )
15571566
15581567 self .doc_button_2 = self .tab2 .findChild (QWidget , "doc_button_2" )
@@ -1565,6 +1574,7 @@ def __init__(self):
15651574 self .doc_button .clicked .connect (self .openDocument )
15661575 self .select_folder_button .clicked .connect (self .select_working_directory )
15671576 self .fd_button .clicked .connect (self .select_fd )
1577+ self .mask_button .clicked .connect (self .select_mask )
15681578 self .ok_button2 .clicked .connect (self .process_data2 )
15691579
15701580 self .doc_button_2 .clicked .connect (self .openDocument_2 )
@@ -1582,6 +1592,7 @@ def __init__(self):
15821592 if central_data_store .NRT is not None :
15831593 self .nrt_entry .setText (str (central_data_store .NRT ))
15841594 self .n_classes = None
1595+ self .mask = None
15851596 self .out_fn = None
15861597 self .out_fn_entry .setPlaceholderText ('e.g., Acre_Vulnerability_HRP.tif' )
15871598
@@ -1628,7 +1639,11 @@ def select_fd(self):
16281639 if file_path :
16291640 self .in_fn = file_path
16301641 self .in_fn_entry .setText (file_path .split ('/' )[- 1 ])
1631-
1642+ def select_mask (self ):
1643+ file_path , _ = QFileDialog .getOpenFileName (self , 'Mask of Study Area' )
1644+ if file_path :
1645+ self .mask = file_path
1646+ self .mask_entry .setText (file_path .split ('/' )[- 1 ])
16321647 def select_working_directory_2 (self ):
16331648 data_folder_2 = QFileDialog .getExistingDirectory (self , "Working Directory" )
16341649 data_folder_path_2 = Path (data_folder_2 )
@@ -1661,8 +1676,8 @@ def process_data2(self):
16611676 QMessageBox .critical (self , "Error" , "Please select the working directory!" )
16621677 return
16631678
1664- if not self .in_fn :
1665- QMessageBox .critical (self , "Error" , "Please select the input file !" )
1679+ if not self .in_fn or not self . mask :
1680+ QMessageBox .critical (self , "Error" , "Please select all input files !" )
16661681 return
16671682
16681683 NRT = self .nrt_entry .text ()
@@ -1719,7 +1734,7 @@ def process_data2(self):
17191734
17201735 try :
17211736 self .vulnerability_map .set_working_directory (directory )
1722- mask_arr = self .vulnerability_map .geometric_classification (self .in_fn , NRT , n_classes )
1737+ mask_arr = self .vulnerability_map .geometric_classification (self .in_fn , NRT , n_classes , self . mask )
17231738 self .vulnerability_map .array_to_image (self .in_fn , out_fn , mask_arr , gdal .GDT_Int16 , - 1 )
17241739 self .vulnerability_map .replace_ref_system (self .in_fn , out_fn )
17251740
@@ -1996,6 +2011,7 @@ def __init__(self):
19962011 self .doc_button = self .tab1 .findChild (QWidget , "doc_button" )
19972012 self .select_folder_button = self .tab1 .findChild (QWidget , "select_folder_button" )
19982013 self .fd_button = self .tab1 .findChild (QWidget , "fd_button" )
2014+ self .mask_button = self .tab1 .findChild (QWidget , "mask_button" )
19992015 self .ok_button2 = self .tab1 .findChild (QWidget , "ok_button2" )
20002016
20012017 self .doc_button_2 = self .tab2 .findChild (QWidget , "doc_button_2" )
@@ -2008,6 +2024,7 @@ def __init__(self):
20082024 self .doc_button .clicked .connect (self .openDocument )
20092025 self .select_folder_button .clicked .connect (self .select_working_directory )
20102026 self .fd_button .clicked .connect (self .select_fd )
2027+ self .mask_button .clicked .connect (self .select_mask )
20112028 self .ok_button2 .clicked .connect (self .process_data2 )
20122029
20132030 self .doc_button_2 .clicked .connect (self .openDocument_2 )
@@ -2025,6 +2042,7 @@ def __init__(self):
20252042 if central_data_store .NRT is not None :
20262043 self .nrt_entry .setText (str (central_data_store .NRT ))
20272044 self .n_classes = None
2045+ self .mask = None
20282046 self .out_fn = None
20292047 self .out_fn_entry .setPlaceholderText ('e.g., Acre_Vulnerability_VP.tif' )
20302048
@@ -2071,6 +2089,11 @@ def select_fd(self):
20712089 if file_path :
20722090 self .in_fn = file_path
20732091 self .in_fn_entry .setText (file_path .split ('/' )[- 1 ])
2092+ def select_mask (self ):
2093+ file_path , _ = QFileDialog .getOpenFileName (self , 'Mask of Study Area' )
2094+ if file_path :
2095+ self .mask = file_path
2096+ self .mask_entry .setText (file_path .split ('/' )[- 1 ])
20742097
20752098 def select_working_directory_2 (self ):
20762099 data_folder_2 = QFileDialog .getExistingDirectory (self , "Working Directory" )
@@ -2104,8 +2127,8 @@ def process_data2(self):
21042127 QMessageBox .critical (self , "Error" , "Please select the working directory!" )
21052128 return
21062129
2107- if not self .in_fn :
2108- QMessageBox .critical (self , "Error" , "Please select the input file !" )
2130+ if not self .in_fn or not self . mask :
2131+ QMessageBox .critical (self , "Error" , "Please select all input files !" )
21092132 return
21102133
21112134 NRT = self .nrt_entry .text ()
@@ -2162,7 +2185,7 @@ def process_data2(self):
21622185
21632186 try :
21642187 self .vulnerability_map .set_working_directory (directory )
2165- mask_arr = self .vulnerability_map .geometric_classification (self .in_fn , NRT , n_classes )
2188+ mask_arr = self .vulnerability_map .geometric_classification (self .in_fn , NRT , n_classes , self . mask )
21662189 self .vulnerability_map .array_to_image (self .in_fn , out_fn , mask_arr , gdal .GDT_Int16 , - 1 )
21672190 self .vulnerability_map .replace_ref_system (self .in_fn , out_fn )
21682191
0 commit comments