# Libraries
library(knitr)
library(units)
library(readxl)
library(sp)
library(raster)
library(tidyverse)
library(getlandsat)
library(sf)
library(mapview)
library(raster)
library(osmdata)
# NVDI
x = (r$NIR - r$Red)/ (r$NIR + r$Red)
ndvi_func = function(x) {
ifelse(x < 0, 1, NA)
}
ndvi = calc(x, ndvi_func)
# NWDI
y = (r$Green - r$NIR)/ (r$NIR + r$Green)
nwdi_func = function(y) {
ifelse(y > 0, 1, NA)
}
ndwi = calc(y, nwdi_func)
# MNDWI
z = (r$Green - r$SWIR1)/ (r$SWIR1 + r$Green)
mnwdi_func = function(z) {
ifelse(z > 0, 1, NA)
}
mndwi = calc(z, mnwdi_func)
# WRI
a = (r$Green + r$Red)/ (r$SWIR1 + r$NIR)
wri_func = function(a) {
ifelse(a > 1, 1, NA)
}
wri = calc(a, wri_func)
# SWI
b = (1)/ sqrt(r$Blue - r$SWIR1)
swi_func = function(b) {
ifelse(b < 5, 1, NA)
}
swi = calc(b, swi_func)
Image band | Area(m2) |
---|---|
NDVI | 5998500 |
NDWI | 6489900 |
MNDWI | 10742400 |
WRI | 7621200 |
SWI | 13680900 |
k-means | 8194500 |