# Cargamos librerías
library(sf)
library(leaflet)
library(leaflet.extras)
library(leaflet.extras2)
# Lectura del archivo
sismos <-st_read('C:\\Users\\RACelis\\Downloads\\sismos.shp')
## Reading layer `sismos' from data source `C:\Users\RACelis\Downloads\sismos.shp' using driver `ESRI Shapefile'
## Simple feature collection with 896 features and 12 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -109.4898 ymin: 0.0001181537 xmax: -109.4896 ymax: 0.0002934269
## Geodetic CRS: WGS 84
# Definición de ícono
icono1 <- awesomeIcons(
icon = 'map-pin',
library = 'fa',
markerColor = 'darkred',
iconColor = 'beige')
# Hacer un mapa de clusters cob ícono personalizado
leaflet() %>%
addTiles () %>%
setView(lng = -100, lat = 20, 4) %>%
addAwesomeMarkers(lng = sismos$X, lat = sismos$Y,icon = icono1, clusterOptions = markerClusterOptions())
estados <- st_read("C:\\Users\\RACelis\\Downloads\\entidades_mx.shp")
## Reading layer `entidades_mx' from data source `C:\Users\RACelis\Downloads\entidades_mx.shp' using driver `ESRI Shapefile'
## Simple feature collection with 32 features and 4 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -118.3651 ymin: 14.5321 xmax: -86.71041 ymax: 32.71865
## Geodetic CRS: WGS 84
# Posición del nombre de la entidad
leaflet(estados) %>%
addPolygons(color = "darkblue", weight = 2, smoothFactor = 0.5, opacity = 0.4, fillOpacity = 0.4, fillColor = "red", highlightOptions = highlightOptions(color = "yellow", weight = 4, bringToFront = TRUE), label = estados$NOMGEO, labelOptions = labelOptions(noHide = F, direction = "right",style = list(
"color" = "black",
"font-family" = "serif",
"font-style" = "italic",
"box-shadow" = "3px 3px rgba(0,0,0,0.25)",
"font-size" = "15px",
"border-color" = "rgba(0,0,0,0.5)")))%>%
addTiles()