This map contains all the hospitals of México City Goberment ( Hospitales y Centros de Salud del Gobierno del Distrito Federal). The data comes from the site “http://www.gobiernoabierto.cdmx.gob.mx”.
setwd("C:/Users/Bruno Gonzalez/16 Movilidad DF")
library(leaflet)
library(reshape)
library(rgdal)
hosp <- read.csv("HospitalesyCentrosdeSaludenelDF-hospitales.csv", header = FALSE)
names(hosp) <- c("Name", "Dean", "Coor")
hosp <- transform(hosp, Coor=colsplit(Coor, split=",", names=c("lng", "lat")))
hosp$Coor$NA. <- NULL
mexico <- readOGR(dsn = ".", layer = "mexico", encoding = "UTF-8")
## OGR data source with driver: ESRI Shapefile
## Source: ".", layer: "mexico"
## with 32 features
## It has 9 fields
leaflet() %>%
addProviderTiles("CartoDB.Positron") %>%
addMarkers(data=hosp$Coor, popup=hosp$Name, clusterOptions=markerClusterOptions()) %>%
addPolygons(data=mexico[9,], color = "steelblue", weight = 1)