#activar biblitecas
library(mapview)
## Warning: package 'mapview' was built under R version 3.6.1
library(raster)
## Warning: package 'raster' was built under R version 3.6.1
## Loading required package: sp
## Warning: package 'sp' was built under R version 3.6.1
#colonias de hermosillo usadas 
library(sf)
## Warning: package 'sf' was built under R version 3.6.1
## Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
library(rgdal)
## Warning: package 'rgdal' was built under R version 3.6.1
## rgdal: version: 1.4-4, (SVN revision 833)
##  Geospatial Data Abstraction Library extensions to R successfully loaded
##  Loaded GDAL runtime: GDAL 2.2.3, released 2017/11/20
##  Path to GDAL shared files: C:/Users/Samsung/Documents/R/win-library/3.6/rgdal/gdal
##  GDAL binary built with GEOS: TRUE 
##  Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
##  Path to PROJ.4 shared files: C:/Users/Samsung/Documents/R/win-library/3.6/rgdal/proj
##  Linking to sp version: 1.3-1
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.6.1
library(ggmap)
## Warning: package 'ggmap' was built under R version 3.6.1
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
library(sp)
library(maptools)
## Warning: package 'maptools' was built under R version 3.6.1
## Checking rgeos availability: TRUE
#Colonias de Hermosillo
hmo <- st_read("coloniashmo.shp")
## Reading layer `coloniashmo' from data source `C:\Users\Samsung\Documents\08_Islas\coloniashmo.shp' using driver `ESRI Shapefile'
## Simple feature collection with 472 features and 6 fields
## geometry type:  POLYGON
## dimension:      XYZ
## bbox:           xmin: 491035.9 ymin: 3205901 xmax: 519788.4 ymax: 3229305
## epsg (SRID):    32612
## proj4string:    +proj=utm +zone=12 +datum=WGS84 +units=m +no_defs
ggplot(hmo) +
  geom_sf()

## Indice de vegetaci昼㸳n NDVI y Temperatura de Julio de 2019

#Mapa de indice de vegetacion NDVI
pal = mapviewPalette("mapviewTopoColors")
ndvi <- raster("hmondvi.tif", package = "mapview")
ndvihmo <- stack(ndvi)
mapview(ndvihmo[[1]], col.regions = pal(100), at = seq(-0.2, 1, 0.2), legend = TRUE)
## Warning in rasterCheckSize(x, maxpixels = maxpixels): maximum number of pixels for Raster* viewing is 5e+05 ; 
## the supplied Raster* has 746460 
##  ... decreasing Raster* resolution to 5e+05 pixels
##  to view full resolution set 'maxpixels =  746460 '
#Mapa de temperatura
pal = mapviewPalette("mapviewRasterColors")
temp <- raster("hmotemp.tif", package = "mapview")
temphmo <- stack(ndvi)
mapview(temphmo [[1]], col.regions = pal(100), at = seq(-0.2, 1, 0.2), legend = TRUE)
## Warning in rasterCheckSize(x, maxpixels = maxpixels): maximum number of pixels for Raster* viewing is 5e+05 ; 
## the supplied Raster* has 746460 
##  ... decreasing Raster* resolution to 5e+05 pixels
##  to view full resolution set 'maxpixels =  746460 '