├── output(180).png ├── Rainfall-Runoff_Table.csv ├── File1 ├── rainfall_runoff_model.py └── README.md /output(180).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Otutu11/Rainfall-Runoff-Modeling-for-Flood-Risk/main/output(180).png -------------------------------------------------------------------------------- /Rainfall-Runoff_Table.csv: -------------------------------------------------------------------------------- 1 | Date,Rainfall_mm,Runoff_mm,Flood_Risk 2 | 2023-09-01,5,0.0,Low 3 | 2023-09-02,12,0.1925039042165541,Low 4 | 2023-09-03,50,19.61237405896862,Low 5 | 2023-09-04,80,43.55311798155493,High 6 | 2023-09-05,30,6.71866843200303,Low 7 | 2023-09-06,0,0.0,Low 8 | 2023-09-07,100,61.00026895413517,High 9 | 2023-09-08,60,27.171220653209744,Low 10 | 2023-09-09,0,0.0,Low 11 | 2023-09-10,25,4.225034966625353,Low 12 | -------------------------------------------------------------------------------- /File1: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # --- Step 1: Sample Rainfall Data (mm/day) --- 6 | data = { 7 | 'Date': pd.date_range(start='2023-09-01', periods=10, freq='D'), 8 | 'Rainfall_mm': [5, 12, 50, 80, 30, 0, 100, 60, 0, 25] # Example daily rainfall 9 | } 10 | 11 | df = pd.DataFrame(data) 12 | 13 | # --- Step 2: Define the Curve Number (CN) --- 14 | CN = 85 # CN values range from 30 to 100 depending on land use/soil type 15 | 16 | # --- Step 3: Calculate Potential Maximum Retention (S) --- 17 | S = (25400 / CN) - 254 # S in mm 18 | 19 | # --- Step 4: Compute Initial Abstraction (Ia) --- 20 | Ia = 0.2 * S 21 | 22 | # --- Step 5: Compute Runoff using SCS Curve Number Method --- 23 | def scs_runoff(P): 24 | if P <= Ia: 25 | return 0 26 | else: 27 | return ((P - Ia) ** 2) / (P - Ia + S) 28 | 29 | df['Runoff_mm'] = df['Rainfall_mm'].apply(scs_runoff) 30 | 31 | # --- Step 6: Flag Flood Risk (e.g., if runoff > 30 mm) --- 32 | flood_threshold = 30 33 | df['Flood_Risk'] = df['Runoff_mm'].apply(lambda x: 'High' if x > flood_threshold else 'Low') 34 | 35 | # --- Step 7: Plot Rainfall and Runoff --- 36 | plt.figure(figsize=(10, 6)) 37 | plt.plot(df['Date'], df['Rainfall_mm'], label='Rainfall (mm)', marker='o') 38 | plt.plot(df['Date'], df['Runoff_mm'], label='Runoff (mm)', marker='x') 39 | plt.axhline(flood_threshold, color='r', linestyle='--', label='Flood Risk Threshold') 40 | plt.title('Rainfall-Runoff Modeling for Flood Risk') 41 | plt.xlabel('Date') 42 | plt.ylabel('Depth (mm)') 43 | plt.legend() 44 | plt.grid(True) 45 | plt.xticks(rotation=45) 46 | plt.tight_layout() 47 | plt.show() 48 | 49 | # --- Step 8: Show Table --- 50 | print(df) 51 | -------------------------------------------------------------------------------- /rainfall_runoff_model.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | # --- Step 1: Sample Rainfall Data (mm/day) --- 6 | data = { 7 | 'Date': pd.date_range(start='2023-09-01', periods=10, freq='D'), 8 | 'Rainfall_mm': [5, 12, 50, 80, 30, 0, 100, 60, 0, 25] # Example daily rainfall 9 | } 10 | 11 | df = pd.DataFrame(data) 12 | 13 | # --- Step 2: Define the Curve Number (CN) --- 14 | CN = 85 # CN values range from 30 to 100 depending on land use/soil type 15 | 16 | # --- Step 3: Calculate Potential Maximum Retention (S) --- 17 | S = (25400 / CN) - 254 # S in mm 18 | 19 | # --- Step 4: Compute Initial Abstraction (Ia) --- 20 | Ia = 0.2 * S 21 | 22 | # --- Step 5: Compute Runoff using SCS Curve Number Method --- 23 | def scs_runoff(P): 24 | if P <= Ia: 25 | return 0 26 | else: 27 | return ((P - Ia) ** 2) / (P - Ia + S) 28 | 29 | df['Runoff_mm'] = df['Rainfall_mm'].apply(scs_runoff) 30 | 31 | # --- Step 6: Flag Flood Risk (e.g., if runoff > 30 mm) --- 32 | flood_threshold = 30 33 | df['Flood_Risk'] = df['Runoff_mm'].apply(lambda x: 'High' if x > flood_threshold else 'Low') 34 | 35 | # --- Step 7: Plot Rainfall and Runoff --- 36 | plt.figure(figsize=(10, 6)) 37 | plt.plot(df['Date'], df['Rainfall_mm'], label='Rainfall (mm)', marker='o') 38 | plt.plot(df['Date'], df['Runoff_mm'], label='Runoff (mm)', marker='x') 39 | plt.axhline(flood_threshold, color='r', linestyle='--', label='Flood Risk Threshold') 40 | plt.title('Rainfall-Runoff Modeling for Flood Risk') 41 | plt.xlabel('Date') 42 | plt.ylabel('Depth (mm)') 43 | plt.legend() 44 | plt.grid(True) 45 | plt.xticks(rotation=45) 46 | plt.tight_layout() 47 | plt.show() 48 | 49 | # --- Step 8: Show Table --- 50 | print(df) 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🌧️ Rainfall-Runoff Modeling for Flood Risk 2 | 3 | This project implements a basic **Rainfall-Runoff Modeling** framework using the **SCS Curve Number (CN) Method** to assess flood risk based on daily rainfall data. It visualizes runoff and flags flood-prone events using a threshold-based system. 4 | 5 | --- 6 | 7 | ## 🧰 Features 8 | 9 | - Estimates runoff from daily rainfall using the **SCS Curve Number method** 10 | - Flags days with **high flood risk** based on runoff threshold 11 | - Generates a clear **time series plot** of rainfall and runoff 12 | - Outputs a tabular dataset with **runoff depth and flood risk status** 13 | 14 | --- 15 | 16 | ## 📈 Methodology 17 | 18 | The **SCS Curve Number (CN)** method is used to calculate surface runoff: 19 | 20 | 1. **Potential Maximum Retention (S):** 21 | 22 | \[ 23 | S = \frac{25400}{CN} - 254 24 | \] 25 | 26 | 2. **Initial Abstraction (Ia):** 27 | 28 | \[ 29 | Ia = 0.2 \cdot S 30 | \] 31 | 32 | 3. **Runoff (Q):** 33 | 34 | \[ 35 | Q = \frac{(P - Ia)^2}{(P - Ia + S)} \quad \text{for } P > Ia, \text{ else } Q = 0 36 | \] 37 | 38 | Where: 39 | - \( P \) = Rainfall in mm 40 | - \( CN \) = Curve Number (based on land use, soil, slope) 41 | - \( Q \) = Runoff in mm 42 | 43 | --- 44 | 45 | ## 📦 Dependencies 46 | 47 | Install the required Python packages: 48 | 49 | ```bash 50 | pip install pandas numpy matplotlib 51 | 52 | 🚀 How to Use 53 | 54 | Clone the repository: 55 | 56 | git clone https://github.com/yourusername/rainfall-runoff-flood-risk.git 57 | cd rainfall-runoff-flood-risk 58 | 59 | Run the script: 60 | 61 | python rainfall_runoff_model.py 62 | 63 | View: 64 | 65 | A plot of rainfall vs runoff with a flood risk threshold 66 | 67 | A table showing dates, rainfall, runoff, and flood risk level 68 | 69 | 📊 Output Sample 70 | Date Rainfall_mm Runoff_mm Flood_Risk 71 | 2023-09-01 5 0.00 Low 72 | 2023-09-04 80 43.55 High 73 | 🔬 Future Work 74 | 75 | Integrate with GIS shapefiles and DEM data 76 | 77 | Use real-time weather API for rainfall input 78 | 79 | Incorporate machine learning for predictive flood modeling 80 | 81 | Extend for HEC-HMS or SWAT integration 82 | 83 | 📜 License 84 | 85 | This project is licensed under the MIT License. 86 | 👨‍💻 Author 87 | 88 | Otutu Anslem 89 | Data Scientist | Flood Risk Analyst 90 | --------------------------------------------------------------------------------