varNDWI: Calculates the normalized difference water index (NDWI)

Description Usage Arguments Details Value References Examples

View source: R/varNDWI.R

Description

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

Usage

1
varNDWI(green, nir)

Arguments

green

a raster with the green band of the capture.

nir

a raster with the NIR band of the capture.

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 \insertCitemcfeeters1996useRGISTools. This function is used within ls7FolderToVar, ls8FolderToVar, modFolderToVar and senFolderToVar.

Value

A NDWI image in raster format.

References

\insertRef

mcfeeters1996useRGISTools

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# path to the cropped and cutted MODIS images for the region of Navarre
wdir <- system.file("ExNavarreVar", package = "RGISTools")
# list all the tif files
files.mod <- list.files(wdir, pattern="\\.tif$", recursive = TRUE, full.names = TRUE)
# print the MOD09 bands
getRGISToolsOpt("MOD09BANDS")

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

RGISTools documentation built on July 2, 2020, 3:58 a.m.