library(mapview)
library(raster)
## Loading required package: sp
pal = mapviewPalette("mapviewTopoColors")

Profundidad <- raster("depth.tif", package = "mapview")
Prof <- stack(Profundidad)

mapview(Prof[[1]], col.regions = pal(100), at = seq(-0.2, 1, 0.2), legend = TRUE)
# the distribution of values in the raster
hist(Prof, main="profundidades de inundacion",
     col= "purple",
     maxpixels=22000000)

#Visualizar los datos

plot(Prof,
     main="inundacion")

summary(Prof)
## Warning in .local(object, ...): summary is an estimate based on a sample of 1e+05 cells (62.81% of all cells)
##                Depth
## Min.    1.029968e-03
## 1st Qu. 9.464645e-01
## Median  1.673088e+00
## 3rd Qu. 2.313713e+00
## Max.    3.899666e+00
## NA's    5.984500e+04
#para filtrar los valores
image(Prof, zlim=c(0.5,0.9))

#Grafico de caja y bigote:
boxplot(Prof)

x <- 0.8
if(x>0.5) {
  "está muy inundado"
} else if (x<0.5) {
  "Está poco inundado"
} else {
  "Esta medianamente inundado"
}
## [1] "está muy inundado"