Loadingg Libraries

library(leaflet)
library(geojsonio)
## Registered S3 method overwritten by 'geojsonsf':
##   method        from   
##   print.geojson geojson
## 
## Attaching package: 'geojsonio'
## The following object is masked from 'package:base':
## 
##     pretty
library(tigris)
## To enable 
## caching of data, set `options(tigris_use_cache = TRUE)` in your R script or .Rprofile.
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.3     v purrr   0.3.4
## v tibble  3.0.4     v dplyr   1.0.2
## v tidyr   1.1.2     v stringr 1.4.0
## v readr   1.4.0     v forcats 0.5.0
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(readxl)
library(sp)
library(rgdal)
## rgdal: version: 1.5-19, (SVN revision 1092)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 3.0.4, released 2020/01/28
## Path to GDAL shared files: C:/Users/Dell/Documents/R/win-library/4.0/rgdal/gdal
## GDAL binary built with GEOS: TRUE 
## Loaded PROJ runtime: Rel. 6.3.1, February 10th, 2020, [PJ_VERSION: 631]
## Path to PROJ shared files: C:/Users/Dell/Documents/R/win-library/4.0/rgdal/proj
## Linking to sp version:1.4-5
## To mute warnings of possible GDAL/OSR exportToProj4() degradation,
## use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal.

Selected sites- Nepal NCDI Poverty Commission

Coordinates mapping

np <- readOGR('npl_admbnda_districts_nd_20201117.shp')
## OGR data source with driver: ESRI Shapefile 
## Source: "C:\Users\Dell\Documents\npl_admbnda_districts_nd_20201117.shp", layer: "npl_admbnda_districts_nd_20201117"
## with 77 features
## It has 14 fields
np$district <- tolower(np$DIST_EN)
visit_dis <- read_excel("visit dis.xlsx")
np <- geo_join(np, visit_dis, 'district', 'district')
np.map <- leaflet(np) %>% addTiles() %>% 
addMarkers( 81.22229030068172, 29.22088191650216, label = as.character("Bayalpata"), popup= paste(" Contact Person <br/> Mandeep Pathak"), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red"))) %>%
  addMarkers(85.33189755277536,27.737720461883303, label = paste("TUTH"),popup= paste(" Contact Person <br/> Sudha Basnet "), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red"))) %>% 
  addMarkers(85.3284720969521,27.73491908808657, label = paste("Kanti"),popup= paste(" Contact Person <br/> Ram Hari Chapagain  "), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red"))) %>%
  addMarkers( 83.44876860064163,27.48981956750972,label ="UCMS", popup= paste("  Contact Person <br/> Raju kafle "), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red"))) %>% 
  addMarkers( 82.18303595281138,29.283150270380833,label = paste("KAHS"),popup= paste("  Contact Person <br/> Sandeep Shrestha  "), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red"))) %>% 
  addMarkers(80.58700203931794,29.299463552727836, label = paste("Dadeldura Hospital"),popup= paste(" Contact Person <br/> Jagadish Mishra"), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red"))) %>% 
  addMarkers(81.6012830492581,28.604698847822398, label = paste("Surkhet Hospital"),popup= paste(" Contact Person <br/> Ramesh Kunwar"), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red"))) %>%
  addMarkers( 81.61748969242389,28.059357340778764, label ="Nepalgunj Medical college", popup= paste(" Contact Person <br/>  Piyush Kanodiya "), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red"))) %>% 
  addMarkers(  83.60034646430158,28.268815586887442,label = paste("Dhaulagiri zonal Hospital"),popup= paste(" Contact Person <br/>  Prakash Thapa "), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red")))%>% 
  addMarkers( 83.99928276802271,28.21390668256406, label = paste("Western regional Hospital Pokhara"),popup= paste(" Contact Person <br/>  Ram Chandra Bastola "), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red"))) %>%
  addMarkers( 84.89635987386376, 27.011330839217358,label ="Natioanl Medical College",popup= paste(" Contact Person <br/>  Atindra Mishra "), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red")))%>% 
  addMarkers( 85.92357667975968,26.733615560514174, label = paste("Janakpur Zonal hospital"),popup= paste(" Contact Person <br/>  Jamun Singh "), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red"))) %>% 
  addMarkers( 87.26834480674674,26.812433307297347, label = paste("BPKIHS"), popup= paste(" Contact Person <br/>  Sanjib Sharma "), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red"))) %>%
  addMarkers(87.27016779140482,26.489978280991416, label ="Nobel Medical Hospital",popup= paste(" Contact Person <br/>  Rajesh Nepal "), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red"))) %>% 
addMarkers( 85.32643316864039,27.731434254360792, label =paste("IFCH"),popup= paste("  Contact Person <br/> TBD "), labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T, textsize="16px", style = list(color="red")))


labels <- sprintf(
  "<strong>%s</strong><br/>%g Hospital Sampled",
  np$DIST_EN, np$count
) %>% lapply(htmltools::HTML)
np.map %>% addPolygons(stroke = T, color = "grey",
                              fillOpacity = 0.3, label = labels)

By District

Nepal

visit_dis <- read_excel("visit dis.xlsx")
d_map <- topojson_read("https://raw.githubusercontent.com/rugnepal/learnRgroup/master/week_13/district.topojson") 

df <- geo_join(d_map, visit_dis, 'district', 'district')
## Warning: `group_by_()` is deprecated as of dplyr 0.7.0.
## Please use `group_by()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
bins <- c(0, 1, 3, Inf)
pal <- colorBin("YlOrRd", domain = df$count, bins = bins)
m <- leaflet(data=df) %>% addPolygons(label= labels, stroke = T, fill = df$count,  color = "red",
                              fillOpacity = 1) %>% 
  addProviderTiles("MapBox", options = providerTileOptions(
    id = "mapbox.light",
    accessToken = Sys.getenv('MAPBOX_ACCESS_TOKEN')))

df$District <- toupper(df$district)
labelss <- sprintf(
  "<strong>%s</strong><br/>%g Hospital Sampled",
  df$District, df$count
) %>% lapply(htmltools::HTML)

m <- m %>% addPolygons(  label = labelss,
  labelOptions = labelOptions(
    style = list("font-weight" = "normal", padding = "3px 8px"),
    textsize = "15px",
    direction = "auto")) 

m