Sentinel-2 NDVI/NDWI Analysis By Brazilian Municipality

by SLV Team 56 views
Sentinel-2 NDVI/NDWI Analysis by Brazilian Municipality

Hey guys! Let's dive into an awesome project focused on analyzing vegetation indices, specifically NDVI (Normalized Difference Vegetation Index) and NDWI (Normalized Difference Water Index), using Sentinel-2 satellite imagery. This project is tailored for Brazilian municipalities (IBGE) and offers a user-friendly interface.

Project Overview: Unveiling Vegetation Health

This project is all about exploring the NDVI and NDWI indices to assess vegetation health and water content across different municipalities in Brazil. It leverages the power of Sentinel-2 data, providing a detailed look at how vegetation changes over time. The user interface is designed to be intuitive, enabling easy navigation and analysis. You'll be able to select a state (UF), then a municipality, define a time period, and choose between NDVI or NDWI. Once the data is loaded, you can export the results for further analysis. The project uses a masked image to ensure data quality. So, let's break down the key features and how they work. This project allows us to visualize and analyze vegetation indices like never before.

Key Features and Functionality

  • User-Friendly Interface: The project boasts a simple and intuitive interface. You don't need to be a GIS expert to get started.
  • State and Municipality Selection: Easily choose a Brazilian state (UF) from a dropdown menu, followed by a specific municipality. This hierarchical structure helps narrow down your area of interest.
  • Date Range Selection: Specify the start and end dates for your analysis. This allows you to examine vegetation changes over a particular time frame.
  • Index Selection: Choose between NDVI and NDWI. NDVI is great for assessing vegetation greenness, while NDWI helps evaluate water content in vegetation.
  • Image Loading: Load the masked image to ensure high-quality data for your analysis.
  • Data Export: Export the processed data to Google Drive for further analysis or sharing.

Setting Up and Running the Analysis

Let's get into how this project works, shall we? You will quickly find that the steps are straightforward. Let's start with the setup and running of the analysis.

Configuration and Data Preparation

Before diving in, let's understand the configuration. The project uses the following constants:

  • ASSET_MUNICIPIOS: This is the location of the shapefile containing the boundaries of Brazilian municipalities (IBGE).
  • MUNICIPIOS_RAW: This variable holds the raw data of the municipalities.
  • SCALE_EXPORT: Sets the export scale for the processed images. You can adjust this for the resolution of your data.

Color Palettes for Visualization

Color palettes are essential for visualizing the NDVI and NDWI data effectively. The project defines two palettes:

  • PALETTE_NDVI: Used for the NDVI index, showing vegetation health with a range of colors.
  • PALETTE_NDWI: Used for the NDWI index, which helps visualize water content.

User Interface and Interaction

The user interface is the heart of this project. Here's a breakdown:

  1. Selection of State: A dropdown menu allows the selection of a Brazilian state (UF). This action triggers the loading of municipalities within the selected state.
  2. Municipality Selection: Once a state is selected, a second dropdown list will be filled with the municipalities of that state.
  3. Date Selection: Text boxes for entering the start and end dates for the image collection.
  4. Index Selection: Buttons for selecting either NDVI or NDWI.
  5. Action Buttons: Buttons for loading and exporting data.

The UI is designed to guide you through the process step by step, which ensures ease of use.

Behind the Scenes: Data Processing

This is where the magic happens! Let's explore the core data processing steps in detail.

Helper Functions

To make the code cleaner and more efficient, several helper functions are defined:

  • getMunicipiosList(uf_sigla): This function retrieves a list of municipalities for a given state (UF). It fetches the municipality data, sorts it, and prepares it for the dropdown menu.
  • setActive(btn): Styles a button to indicate that it is active.
  • setInactive(btn): Styles a button to indicate that it is inactive.
  • maskS2SR(img): Masks the Sentinel-2 images to remove clouds and other atmospheric interference. This ensures cleaner data.
  • computeIndex(img): Calculates the NDVI or NDWI based on the user's selection. This function normalizes the difference between the bands for accurate vegetation and water assessment.
  • currentViz(): Returns the correct visualization parameters based on the selected index (NDVI or NDWI).

Masking and Index Computation

  • Cloud Masking: The maskS2SR function is crucial for data quality. It removes clouds, cloud shadows, and other issues that can affect the analysis. The masking ensures that the indices calculated are based on reliable data.
  • Index Calculation: The computeIndex function calculates the NDVI or NDWI based on the user's choice.

Loading and Exporting Data

  • Loading the Image: The btnLoad.onClick function handles the loading process. It first checks for a selected municipality and then retrieves the Sentinel-2 image collection for the specified date range. The images are then cloud-masked and the index (either NDVI or NDWI) is computed.
  • Exporting Data: The btnExport.onClick function allows users to export the processed index image to Google Drive. The exported image will be ready for further analysis or integration with other applications.

Conclusion: Your Next Steps

This project provides a complete workflow for analyzing NDVI and NDWI using Sentinel-2 data. Whether you're a researcher, student, or enthusiast, this tool offers a great way to monitor vegetation health across Brazilian municipalities.

Using the Project Effectively

  1. Select a State (UF): Start by choosing the state of interest from the dropdown menu.
  2. Choose a Municipality: Once the municipalities load, select the specific municipality you want to analyze.
  3. Set the Date Range: Enter the start and end dates for your analysis.
  4. Select an Index: Choose whether to analyze NDVI or NDWI.
  5. Load the Image: Click the