Learn R Programming

RGISTools (version 0.9.7)

varNDWI: Calculates normalized difference water index (NDWI)

Description

varNDWI Calculate the normalized difference water index (NDWI) from the green and near-infrared (NIR) bands.

Usage

varNDWI(green, nir)

Arguments

green

a raster with the green band of the capture.

nir

a raster with the NIR band of the capture.

Value

A NDWI image in raster format.

Details

The normalized difference water index (NDWI) is a ratio between the green and near-infrared bands of the spectrum that was developed to detect open water areas and minimize the influence of the soil and vegetation variations mcfeeters1996useRGISTools. This function is used within ls7FolderToVar, ls8FolderToVar, modFolderToVar and senFolderToVar.

References

mcfeeters1996useRGISTools

Examples

Run this code
# NOT RUN {
# path to the cropped and cutted MODIS images for the region of Navarre
img.dir <- system.file("ExNavarreVar", package = "RGISTools")
# list all the tif files
img.files <- list.files(img.dir, pattern="\\.tif$", recursive = TRUE, full.names = TRUE)
# print the MOD09 bands
getRGISToolsOpt("MOD09BANDS")

# select the green and NIR bands
green <- raster(img.files[4])
nir <- raster(img.files[2])
# calculate the NDWI image
ndwi <- varNDWI(green,nir)
# plot the image
spplot(ndwi,col.regions=rev(rainbow(20)))
# }

Run the code above in your browser using DataLab