GIND-VGH NDVI/EVI Assessment

Author

Andrei Pyko

Published

February 17, 2025

Overview

GIND-VGH – Greenness INdex for DVI in Västra Götaland & Halland

GIND-VGH is a regional study aimed at assessing NDVI/EVI greenness data for Västra Götaland and Halland to support environmental and epidemiological research. The project involves processing geospatial data, extracting vegetation indices, and integrating them into various analytical frameworks. The assessment leverages Normalized Difference Vegetation Index (NDVI) data to quantify greenness at multiple spatial levels and ensure consistency in exposure metrics over time.

Data Processing and Preparation

The study utilizes NDVI/EVI raster data spanning multiple years, with processing conducted using QGIS and GDAL commands. The data is extracted for relevant regions, clipped to specific extents, and aggregated over multi-year periods to provide stable exposure estimates.

Each raster is processed within its respective folder, and the clipped outputs are saved in a designated subfolder corresponding to the project title.

Batch Processing of Multiple Raster Files

To process NDVI data across multiple years and generate aggregated outputs within R:

library(stringr)

# Define paths
path_to_tif <- paste0(prefix,"Greenness/2024_NDVI/KI_Leverans/Sverige/")
path_to_cropped <- paste0(prefix,"Greenness/2024_NDVI/KI_Leverans/Sverige/clipped")
cropped_coordinates <- '267423.03 6572635.216 483482.1955 6243554.671'
target_year<-seq(2018,2023)

# List all .tif files in the directory
all_tif_files <- list.files(path_to_tif, pattern = "\\.tif$", full.names = TRUE)

# Extract years from filenames
years <- unique(str_extract(basename(all_tif_files), "\\d{4}"))
years <- na.omit(as.numeric(years))  # Ensure numeric values

#keep only years overlapping with target years
years<-years[years %in% target_year]

for (year in years) {
  # year<-2018
  # Filter files for the specific year as "2018-median"
  year_files <- all_tif_files[str_detect(basename(all_tif_files), paste0(year, "-median"))]
  
  
  for (file in year_files) {
    # file<-year_files[1]
    # Define output file path as original file and _clipped as postfix
    output_file <- file.path(path_to_cropped, str_replace(basename(file), ".tif", "_clipped.tif"))
    
    cmd <- paste0(
      "cmd.exe /c \"C:\\OSGeo4W\\OSGeo4W.bat && gdal_calc.bat ",
      paste0(" --overwrit -A ", shQuote(file), " --A_band 1"),
      " --calc=\"A\"",
      " --format=GTiff",
      " --projwin ", cropped_coordinates,
      " --type=Int16",
      " --NoDataValue=-9999",
      " --outfile=\"", output_file, "\""
    )
    
    system(cmd, intern = TRUE)
  }
}

Shareing of files with GU group

As agreed with MÖ file will be shared via GU Box.

# Get all files in output folder
output_files <- list.files(path_to_cropped, pattern = "\\.tif$", full.names = FALSE)

# Print output files as a markdown list
cat(paste0("- ", output_files, collapse = "\n"))
- Composite_L8_2018-median_filtered_EVI_int16_clipped.tif
- Composite_L8_2018-median_filtered_NDVI_int16_clipped.tif
- Composite_L8_2019-median_filtered_EVI_int16_clipped.tif
- Composite_L8_2019-median_filtered_NDVI_int16_clipped.tif
- Composite_L8_2020-median_filtered_EVI__int16_clipped.tif
- Composite_L8_2020-median_filtered_NDVI_int16_clipped.tif
- Composite_L8_2021-median_filtered_EVI__int16_clipped.tif
- Composite_L8_2021-median_filtered_NDVI_int16_clipped.tif
- Composite_L8_2022-median_filtered_EVI__int16_clipped.tif
- Composite_L8_2022-median_filtered_NDVI_int16_clipped.tif
- Composite_L8_2023-median_filtered_EVI_int16_clipped.tif
- Composite_L8_2023-median_filtered_NDVI_int16_clipped.tif