joaopimenta commited on
Commit
fb51a82
·
verified ·
1 Parent(s): 5fdf120

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -304
app.py CHANGED
@@ -2322,307 +2322,4 @@ elif page == "Worldwide Analysis":
2322
  else:
2323
  st.write("Please select the date range and cloud coverage thershold for the analysis.")
2324
  else:
2325
- st.write("Please search on the map the lake you want to analyse and click on it to select it")
2326
-
2327
- elif page =="About":
2328
-
2329
- from PIL import Image
2330
- # For handling images
2331
- # Load images
2332
- satellite_image = Image.open("/Users/joaopimenta/Desktop/images thesis and figures/Captura de ecrã 2024-08-29, às 18.17.19.png")
2333
- workflow_diagram = Image.open("/Users/joaopimenta/Downloads/image-Photoroom.png")
2334
- reservoir_map = Image.open("/Users/joaopimenta/Desktop/images thesis and figures/Captura de ecrã 2024-08-30, às 00.43.24.png")
2335
- worflow_image = Image.open("/Users/joaopimenta/Desktop/SCR-20241218-bmyx.png")
2336
- #comparison_graph = Image.open("images/comparison_graph.jpg")
2337
- #future_advancements = Image.open("images/future_advancements.jpg")
2338
- # Path to your video file
2339
- st.markdown(" ")
2340
- st.markdown(" ")
2341
- st.markdown(" ")
2342
- st.markdown(" ")
2343
- st.markdown(" ")
2344
- st.markdown(" ")
2345
- st.markdown(" ")
2346
- st.markdown(" ")
2347
- st.markdown(" ")
2348
- st.markdown(" ")
2349
- st.markdown(" ")
2350
- st.markdown(" ")
2351
- st.markdown(" ")
2352
- st.markdown(" ")
2353
- st.markdown(" ")
2354
- st.markdown(" ")
2355
-
2356
- st.markdown(
2357
- """
2358
- <style>
2359
- .about-text {
2360
- font-family: 'Times New Roman', Times, serif;
2361
- font-size: 40px;
2362
- line-height: 1.6;
2363
- max-width: 1000px;
2364
- margin: 0 auto;
2365
- text-align: justify;
2366
- }
2367
- </style>
2368
- """,
2369
- unsafe_allow_html=True
2370
- )
2371
- # Content with the "about-text" class for styling
2372
- st.markdown(
2373
- """
2374
- <div class="about-text">
2375
- <h1>About the Research</h1>
2376
- <p>
2377
- Efficient management of water reservoirs is essential for water security, flood control, and hydroelectric power generation.
2378
- Traditional methods of evaluating reservoir volumes depend on in-situ measurements and physical surveys, which are often
2379
- time-consuming, resource-intensive, and impractical for many regions due to financial and logistical limitations.
2380
- </p>
2381
- <p>
2382
- To address these challenges, this research introduces a novel remote sensing tool designed to provide an accurate, scalable,
2383
- and globally accessible method for reservoir volume evaluation. The tool integrates high-resolution Sentinel-2 satellite imagery
2384
- with geospatial analysis techniques and machine learning algorithms to automatically calculate inundated areas and reservoir water storage.
2385
- </p>
2386
- <p>
2387
- This problem is both significant and complex. Reservoir volume measurements are critical for effective water resource management,
2388
- yet current methodologies struggle to scale for large or remote areas due to high costs. Furthermore, environmental factors such as
2389
- cloud cover and human-made structures, like bridges, can interfere with satellite imagery, presenting additional challenges for large-scale
2390
- remote sensing. By employing the algorithms developed in this study, the proposed tool overcomes these barriers, delivering flexible
2391
- and reliable estimates of reservoir volumes.
2392
- </p>
2393
- <p>
2394
- The solution was tested on reservoirs in Portugal and California, USA, achieving high accuracy. Results showed an average mean absolute
2395
- percentage error of <strong>5.35%</strong> and an average correlation coefficient (<strong>R²</strong>) of <strong>0.90</strong> when compared to published data obtained
2396
- through traditional methods.
2397
- </p>
2398
- <p>
2399
- This software includes a free demo version designed to allow users to test the tool, with continuous improvements planned. Currently, it utilizes a sample of polygons
2400
- from the SWOT lakes database, covering 93% of all lakes across Europe.
2401
- Over time, the database will be expanded, incorporating additional data, while also optimizing the website's RAM usage.
2402
- </p>
2403
- <p>
2404
- Beyond the current promising results, this research opens pathways for future enhancements. These include:
2405
- </p>
2406
- <ul>
2407
- <li>Incorporating additional satellite data sources such as <strong>SWOT</strong> (Surface Water and Ocean Topography)</li>
2408
- <li>Updating bathymetric datasets</li>
2409
- <li>Integrating predictive <strong>LSTM</strong> (Long Short-Term Memory) models to forecast reservoir volumes under varying climate scenarios</li>
2410
- </ul>
2411
- </div>
2412
- """,
2413
- unsafe_allow_html=True
2414
- )
2415
- col1, col2, col3 = st.columns([1, 2, 1])
2416
- with col2:
2417
- st.image(worflow_image, caption="App description", width=700)
2418
- st.markdown(
2419
- """
2420
- <div class="about-text">
2421
- <h1>About This Application</h1>
2422
- <h1>Revolutionizing Water Resource Management</h1>
2423
- <p>
2424
- The Reservoir Volume Monitoring Application is a cutting-edge tool designed to address global challenges in water management, flood prevention, and hydroelectric power optimization. By leveraging high-resolution satellite imagery from Sentinel-2 and advanced geospatial analysis, the app automates the estimation of reservoir volumes, delivering accurate, efficient, and globally scalable solutions.This software includes a free demo version designed to allow users to test the tool, with continuous improvements planned. Currently, it utilizes a sample of polygons
2425
- from the SWOT lakes database, covering 93% of all lakes across Europe.
2426
- Over time, the database will be expanded, incorporating additional data, while also optimizing the website's RAM usage.
2427
- </ul>
2428
- </div>
2429
- """,
2430
- unsafe_allow_html=True
2431
- )
2432
- # Image in the middle column
2433
- col1, col2, col3 = st.columns([1, 2, 1])
2434
- with col2:
2435
- st.image(satellite_image, caption="Sentinel-2 satellite image of a large reservoir", width=700,)
2436
- st.markdown(
2437
- """
2438
- <div class="about-text">
2439
- <h1>How It Works</h1>
2440
- <p>
2441
- This application simplifies complex workflows into an intuitive and automated process. Users start by selecting a Region of Interest (ROI) using an interactive map or by uploading geojson files. Satellite imagery for the specified area and date range is automatically retrieved and preprocessed. Advanced algorithms remove interferences such as clouds, shadows, or structural obstacles like bridges.
2442
- The app applies indices such as NDWI (Normalized Difference Water Index) to classify water pixels and calculate inundated areas. For reservoirs affected by cloud cover, bathymetric data from global databases like GLOBathy is used to reconstruct accurate water surfaces. Finally, volumes are calculated using area-volume relationships derived from either existing databases or user-provided data. The results are visualized through dynamic charts, maps, and downloadable reports, providing users with actionable insights.
2443
- </ul>
2444
- </div>
2445
- """,
2446
- unsafe_allow_html=True
2447
- )
2448
- col1, col2, col3 = st.columns([1, 2, 1])
2449
- with col2:
2450
- st.image(workflow_diagram, caption="Workflow of the app: From data acquisition to volume estimation", width=700)
2451
- st.markdown(
2452
- """
2453
- <div class="about-text">
2454
- <h1>Why It Matters</h1>
2455
- <p>
2456
- Reservoirs are crucial for ensuring water security, supporting agriculture, producing hydroelectric power, and maintaining ecological balance. However, many regions lack efficient monitoring tools, leading to water mismanagement and heightened risks of droughts, floods, and ecological disruption.
2457
- This application bridges the gap by offering a globally accessible solution that requires no physical infrastructure. Its scalability enables it to monitor reservoirs of all sizes, from local irrigation ponds to massive hydroelectric reservoirs. With an accuracy of 94.65%, tested on reservoirs in Portugal and California, the app provides reliable data to support decision-making in water management, flood risk mitigation, and ecosystem preservation.
2458
- </ul>
2459
- </div>
2460
- """,
2461
- unsafe_allow_html=True
2462
- )
2463
-
2464
- st.markdown(
2465
- """
2466
- <div class="about-text">
2467
- <h1>Key Benefits</h1>
2468
- <p>
2469
- The application offers a robust yet user-friendly platform that integrates cutting-edge technology into a seamless user experience. Built with Python and the Streamlit framework, it provides:
2470
- • Automated Image Processing: Reduces manual effort by leveraging advanced algorithms for water surface detection and volume calculation.
2471
- • Accurate Data Insights: Achieves a mean absolute percentage error of just 5.35%.
2472
- • Global Scalability: Access anywhere, monitor reservoirs of all sizes, and ensure reliable data even in remote areas.
2473
- • Environmental Sustainability: Supports efficient water use and better management of natural resources.
2474
- </ul>
2475
- </div>
2476
- """,
2477
- unsafe_allow_html=True
2478
- )
2479
- col1, col2, col3 = st.columns([1, 2, 1])
2480
- with col2:
2481
- st.image(reservoir_map, caption="Tested reservoirs in Portugal and California", width=700)
2482
- st.markdown(
2483
- """
2484
- <div class="about-text">
2485
- <h1>The Future of Reservoir Monitoring<h1>
2486
- <p>
2487
- The application is poised for future enhancements, including integration with new satellite missions like SWOT (Surface Water and Ocean Topography), predictive modeling using LSTM algorithms, and expanded compatibility with emerging geospatial technologies. With its scalable and adaptable design, this tool is set to become an indispensable resource for water resource management professionals, researchers, and environmental advocates.
2488
- </ul>
2489
- </div>
2490
- """,
2491
- unsafe_allow_html=True
2492
- )
2493
-
2494
- # Contact Section
2495
- st.header("Contact Me")
2496
-
2497
- # Creating three columns
2498
- col1, col2, col3 = st.columns([1, 2, 1])
2499
-
2500
- # Place email in the first column
2501
- with col1:
2502
- st.markdown(
2503
- """
2504
- **Email:**
2505
2506
- """,
2507
- unsafe_allow_html=True
2508
- )
2509
-
2510
- # Place GitHub link in the second (middle) column
2511
- with col2:
2512
- st.markdown(
2513
- """
2514
- **GitHub:**
2515
- [github.com/yourusername](https://github.com/yourusername)
2516
- """,
2517
- unsafe_allow_html=True
2518
- )
2519
-
2520
- # Place LinkedIn link in the third column
2521
- with col3:
2522
- st.markdown(
2523
- """
2524
- **LinkedIn:**
2525
- [www.linkedin.com/in/joão-pimenta-mp](www.linkedin.com/in/joão-pimenta-mp)
2526
- """,
2527
- unsafe_allow_html=True
2528
- )
2529
- elif page =="Tutorial":
2530
-
2531
- st.markdown("""
2532
- # Tutorial: Analyzing Satellite Imagery and Calculating Reservoir Volumes
2533
-
2534
- Welcome to the tutorial for your app, which automates the process of analyzing satellite imagery and calculating the area and volume of reservoirs. This guide will walk you through the steps to use the app effectively.
2535
-
2536
- ---
2537
-
2538
- ## Step 1: Define the Region of Interest (ROI)
2539
-
2540
- 1. **Set the Region of Interest (ROI)**
2541
- Start by defining the Region of Interest (ROI), which is the geographic area you want to analyze. You can specify this by selecting coordinates or using a map interface to draw a boundary around the reservoir.
2542
- **Tip:** You can zoom in and adjust the shape of the ROI for more precise selection.
2543
-
2544
- ---
2545
-
2546
- ## Step 2: Define the Date Range
2547
-
2548
- 1. **Select the Date Range**
2549
- The next step is to choose a date range for the analysis. You can use the calendar interface within the app to select the start and end dates for the period you wish to analyze.
2550
- The app will automatically filter available satellite imagery based on the selected date range and cloud coverage.
2551
-
2552
- ### Cloud Coverage Percentage Filter:
2553
- The app will display images for the chosen date range and allow you to choose the maximum acceptable percentage of cloud coverage for the images.
2554
- **Tip:** To ensure clear images, select a lower cloud coverage threshold (e.g., less than 10%).
2555
-
2556
- ---
2557
-
2558
- ## Step 3: Confirm the Reservoir Selection
2559
-
2560
- 1. **Select the Reservoir**
2561
- After defining the ROI and setting the date range, the app will retrieve satellite imagery for the region. You will be shown a list of possible reservoirs within the selected area.
2562
- Review the options and confirm the specific reservoir you want to analyze.
2563
- **Tip:** If the app detects multiple water bodies, it will present thumbnails or maps to help you identify the correct reservoir.
2564
-
2565
- ---
2566
-
2567
- ## Step 4: Choose the Cloud Coverage Percentage
2568
-
2569
- 1. **Choose Cloud Coverage Threshold**
2570
- You will now select the cloud coverage threshold. The app will show you images with varying levels of cloud coverage.
2571
- You can choose a cloud coverage percentage that meets your needs (e.g., less than 10%, 20%, etc.).
2572
- **Tip:** For more accurate results, choose a threshold that minimizes the impact of cloud cover on your analysis.
2573
-
2574
- ---
2575
-
2576
- ## Step 5: Choose the Output Variables
2577
-
2578
- 1. **Select Output Variables**
2579
- Now, you can choose the specific variables you want the app to calculate for the reservoir. These may include:
2580
- - Water Area
2581
- - Volume
2582
- - Time Series Data for Volume
2583
- - Bathymetric Information
2584
- **Tip:** Select the variables you are most interested in, such as volume or changes over time.
2585
-
2586
- ---
2587
-
2588
- ## Step 6: Press the "Start" Button
2589
-
2590
- 1. **Start the Analysis**
2591
- Once all parameters have been defined (date range, reservoir selection, cloud coverage, and output variables), you can initiate the analysis by pressing the **"Start"** button.
2592
- The app will begin processing the satellite imagery, applying necessary corrections, and performing calculations to estimate the reservoir's water area and volume.
2593
- **Tip:** Depending on the data size, the process may take a few minutes. You’ll see a progress indicator during this time.
2594
-
2595
- ---
2596
-
2597
- ## Step 7: View and Export Results
2598
-
2599
- 1. **View Results**
2600
- Once the analysis is complete, you can view the results directly within the app. The app will display visualizations of the water area and provide calculated volume data for the reservoir.
2601
-
2602
- 2. **Export Data**
2603
- You can export the analysis results in CSV, Excel, or other formats for further analysis or reporting. Simply click the "Export" button to download the data.
2604
-
2605
- ---
2606
-
2607
- ## Notes
2608
-
2609
- 1. **Fill the parameters**
2610
- In order for the software to compute the water analysis all the paremeters must have been adressed
2611
-
2612
- 2. **Statistics**
2613
- Note that 'higher percentage' and 'lower percentage' values are calulated based on the maxiumum and minum water volume value from the calculated time series comparing with the maximum water volume present on the SWOT lakes database for that specific reservoir
2614
-
2615
- ---
2616
-
2617
- ## Conclusion
2618
-
2619
- By following these steps, you can efficiently analyze satellite imagery and calculate reservoir volumes using the app. The methodology ensures accurate results with cloud coverage filtering, error checking, and reliable bathymetric analysis.
2620
-
2621
- If you encounter any issues or need further assistance, refer to the help section within the app or contact support.
2622
- """)
2623
- video_file = open('/Users/joaopimenta/Desktop/Gravação do ecrã 2024-11-08, às 00.40.22.mov', "rb")
2624
- video_bytes = video_file.read()
2625
-
2626
- st.video(video_bytes)
2627
-
2628
- # For handling images
 
2322
  else:
2323
  st.write("Please select the date range and cloud coverage thershold for the analysis.")
2324
  else:
2325
+ st.write("Please search on the map the lake you want to analyse and click on it to select it")