ndvi | R Documentation |
This function will calculate the Normalized Difference Vegetation Index from raster data sets - either in memory, or as files (which will be rastered), defined as:
NDVI = (NIR - RED) / (NIR + RED)
The NDVI will be calculated from pure DN as default, however, an option to caculate the NDVI based on reflectance is implemented according to the procedure by Chander et al. (2009). See argument 'calc.ref' for more information.
ndvi(NIR,RED, ...)
NIR |
File containing the NIR information for calculation. |
RED |
File containing the RED information for calculation. |
write |
Specify, if the resulting NDVI grid should be written to file.Default = F (T/F) |
outpath |
User defined outpath to write the final NDVI file. |
outname |
User defined name for the resulting file.(Default name / format: 'ndvi.tif' |
calc.ref |
Should the NDVI be calculated from reflectance? Default = FALSE, NDVI will be calculated from DN only. If set TRUE, make sure to provide the date of the scene. See date for further information. |
sensor |
Sensor for NDVI calculation. Default "tm", other option: "etm+". Only important if calc.ref = TRUE. |
Date |
Date of the scene (overpassing date). Format POSIXct, e.g. "1990-01-10". Default is "1990-01-01". Only important if calc.ref = TRUE. |
Lmin.red,... |
Calibration parameter files for the sensor. Landsat TM and ETM+ are implemented, if images originate from a different sensor, these parameters should be adjusted. Only relevant if calc.ref =T. |
Note: calculation of the NDVI for a larger scene (e.g. one entire Landsat image) will require a lot of time and memory! If only a smaller part of the image is needed, consider to crop the image first. Conversion to reflectance according to Chander et al. (2009).
RasterLayer .tiff file
NIR<- raster(ncol=30,nrow=20) NIR [] <- runif(30*20,min = 1,max = 255) RED <- raster(ncol=30,nrow=20) RED [] <- runif(30*20,min = 1,max = 255) NDVI = ndvi(NIR,RED) plot(NDVI) ### using example data act.ndvi = ndvi(red,nir,cal.reflectance = TRUE, date = "1980-11-14") plot(act.ndvi)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.