|
1 | 1 | ############+++++++++++ PLEASE MAKE SURE OF THE FOLLOWING POINTS BEFORE RUNNING THE CODE +++++++++++############ |
2 | 2 | # [1]. Data are already downloaded (Satellite images and DEM) |
3 | | -# [2]. DEM should be in the projected coordinate system (unit: meters) |
4 | | -# [3]. Use the same coordinates that you have used in "data_download.py" |
5 | | -# [4]. All the python(scripts) files are inside ".../ReservoirExtraction/codes" |
6 | | -# [5]. "Number_of_tiles" = Number of Landsat tiles to cover the entire reservoir. It is recommended to download the Landsat tile covering the maximum reservoir area |
| 3 | +# [2]. Use the same coordinates that you have used in "data_download.py" |
| 4 | +# [3]. All the python(scripts) files are inside ".../ReservoirExtraction/codes" |
7 | 5 | ############++++++++++++++++++++++++++++++++++++++++ END ++++++++++++++++++++++++++++++++++++++++############# |
8 | 6 |
|
9 | 7 | # IMPORTING LIBRARY |
10 | 8 |
|
11 | 9 | import os |
12 | | -os.chdir("H:/My Drive/NUSproject/ReservoirExtraction/") |
| 10 | +os.chdir("G:/My Drive/NUSproject/ReservoirExtraction/") |
13 | 11 | from codes.CURVE import curve |
14 | | -from codes.CURVE import res_iso |
| 12 | +from codes.CURVE import res_isolation |
15 | 13 | from codes.MASK import mask |
16 | 14 | from codes.WSA import wsa |
17 | 15 | from codes.PREPROCESING import preprocessing |
18 | 16 | from codes.CURVE_Tile import one_tile |
19 | | -from codes.CURVE_Tile import two_tile |
20 | | - |
21 | 17 |
|
22 | 18 | if __name__ == "__main__": |
23 | 19 |
|
24 | 20 | #====================================>> USER INPUT PARAMETERS |
25 | | - parent_directory = "H:/My Drive/NUSproject/ReservoirExtraction/Reservoirs/" |
| 21 | + parent_directory = "G:/My Drive/NUSproject/ReservoirExtraction/Reservoirs/" |
26 | 22 | os.chdir(parent_directory) |
27 | | - res_name = "Xayabouri_part2" # Name of the reservoir |
28 | | - res_directory = parent_directory + res_name |
29 | | - # A point within the reservoir [longitude, latitude] |
30 | | - point = [101.813, 19.254] |
31 | | - # Upper-Left and Lower-right coordinates. Example coordinates [longitude, latitude] |
32 | | - boundary = [101.754, 19.534, 101.958, 19.240] #[107.763, 14.672, 107.924, 14.392] |
33 | | - max_wl = 285 |
34 | | - os.makedirs(res_name, exist_ok=True) |
35 | | - os.chdir(parent_directory + res_name) |
36 | | - # Create a new folder within the working directory to download the data |
37 | | - os.makedirs("Outputs", exist_ok=True) |
38 | | - # Path to DEM (SouthEastAsia_DEM30m.tif), PCS: WGS1984 |
39 | | - dem_file_path = "H:/My Drive/NUSproject/ReservoirExtraction/SEAsia_DEM/SouthEastAsia_DEM30m.tif" |
40 | | - |
41 | | - #====================================>> FUNCTION CALLING -1 |
42 | | - # [1]. Data pre-processing (reprojection and clipping) |
43 | | - preprocessing(res_name, point, boundary, parent_directory, dem_file_path) |
44 | | - |
45 | | - #====================================>> FUNCTION CALLING -2 |
46 | | - # [2]. DEM-based reservoir isolation |
47 | | - res_iso(res_name, max_wl, point, boundary, res_directory) |
48 | | - |
49 | | - #====================================>> FUNCTION CALLING -3 |
50 | | - # [3]. Creating mask/intermediate files |
51 | | - mask(res_name, max_wl, point, boundary, res_directory) |
52 | | - |
53 | | - #====================================>> FUNCTION CALLING -4 |
54 | | - # [4]. DEM-Landsat-based updated Area-Elevation-Storage curve |
55 | | - res_minElev = curve(res_name, res_directory) |
56 | | - |
57 | | - #====================================>> FUNCTION CALLING -5 |
58 | | - # [5]. Calculating the water surface area |
59 | | - os.chdir(res_directory) |
60 | | - wsa(res_name, res_directory) |
61 | | - |
62 | | - #====================================>> FUNCTION CALLING -6 |
63 | | - # [6]. Calculating the reservoir restorage (1 tiles) |
64 | | - os.chdir(res_directory) |
65 | | - one_tile(res_name, max_wl, res_minElev, res_directory) |
66 | | - |
| 23 | + res_name = "Xiaowan" |
| 24 | + res_built_year = 2010 |
| 25 | + dem_acquisition_year = 2000 #SRTM DEM (30m) acquired in Feb 2000 |
| 26 | + |
| 27 | + if res_built_year > dem_acquisition_year: |
| 28 | + res_directory = parent_directory + res_name |
| 29 | + # A point within the reservoir [longitude, latitude] |
| 30 | + point = [99.95, 24.745] |
| 31 | + # Upper-Left and Lower-right coordinates. Example coordinates [longitude, latitude] |
| 32 | + boundary = [99.20, 25.60, 100.25, 24.65] |
| 33 | + max_wl = 1236 |
| 34 | + os.makedirs(res_name, exist_ok=True) |
| 35 | + os.chdir(parent_directory + res_name) |
| 36 | + # Create a new folder within the working directory to download the data |
| 37 | + os.makedirs("Outputs", exist_ok=True) |
| 38 | + # Path to DEM (SouthEastAsia_DEM30m.tif), PCS: WGS1984 |
| 39 | + # We have a bigger DEM file that is being used to clip the reservoir-DEM |
| 40 | + dem_file_path = "G:/My Drive/NUSproject/ReservoirExtraction/SEAsia_DEM/SouthEastAsia_DEM30m.tif" |
| 41 | + |
| 42 | + #====================================>> FUNCTION CALLING -1 |
| 43 | + # [1]. Data pre-processing (reprojection and clipping) |
| 44 | + preprocessing(res_name, point, boundary, parent_directory, dem_file_path) |
| 45 | + |
| 46 | + #====================================>> FUNCTION CALLING -2 |
| 47 | + # [2]. DEM-based reservoir isolation |
| 48 | + os.chdir(parent_directory + res_name + '/Outputs') |
| 49 | + res_isolation(res_name, max_wl, point, boundary, res_directory) |
| 50 | + |
| 51 | + #====================================>> FUNCTION CALLING -3 |
| 52 | + # [3]. Creating mask/intermediate files |
| 53 | + os.chdir(parent_directory + res_name + '/Outputs') |
| 54 | + mask(res_name, max_wl, point, boundary, res_directory) |
| 55 | + |
| 56 | + #====================================>> FUNCTION CALLING -4 |
| 57 | + # [4]. DEM-Landsat-based updated Area-Elevation-Storage curve |
| 58 | + os.chdir(parent_directory + res_name + '/Outputs') |
| 59 | + res_minElev = curve(res_name, res_directory) |
| 60 | + |
| 61 | + #====================================>> FUNCTION CALLING -5 |
| 62 | + # [5]. Calculating the water surface area |
| 63 | + os.chdir(res_directory) |
| 64 | + wsa(res_name, res_directory) |
| 65 | + |
| 66 | + #====================================>> FUNCTION CALLING -6 |
| 67 | + # [6]. Calculating the reservoir restorage (1 tiles) |
| 68 | + os.chdir(res_directory) |
| 69 | + one_tile(res_name, max_wl, res_minElev, res_directory) |
| 70 | + |
| 71 | + |
| 72 | +# Finally moving all .png files in a seperate folder for better organisation |
| 73 | +import shutil |
| 74 | +# Create a folder to store the pictures if it doesn't exist |
| 75 | +pictures_folder = "intermediate_pictures" |
| 76 | +os.makedirs(pictures_folder, exist_ok=True) |
| 77 | +# List all files in the current directory |
| 78 | +files = os.listdir() |
| 79 | +# Move all PNG files to the 'pictures' directory |
| 80 | +for file in files: |
| 81 | + if file.lower().endswith(".png"): |
| 82 | + file_path = os.path.join(os.getcwd(), file) |
| 83 | + shutil.move(file_path, os.path.join(pictures_folder, file)) |
| 84 | + |
67 | 85 |
|
68 | 86 |
|
69 | 87 |
|
|
0 commit comments