What is the Human Development Index?


HDI/IPM explains how residents can access the results of development in obtaining income, health, education, and so on. HDI was introduced by the United Nations Development Program (UNDP) in 1990 and is published regularly in the annual Human Development Report (HDR) report.

HDI is formed by three basic dimensions: * Long life and healthy life * Knowledge * Decent standard of living

Load Packages and Read Map Data


I will be trying out to mapping using leaflet. For the first, load all the necessary packages that we will use during process.

library(readxl)
library(dplyr)
library(geojsonio)
library(leaflet)
library(knitr)

# Json Base Maps
jatim_json <- geojson_read("C:/Users/agus/Documents/Map Indonesia/kab_indonesia.json", what = "sp")

glimpse(jatim_json@data) 
## Observations: 502
## Variables: 13
## $ GID_0     <chr> "IDN", "IDN", "IDN", "IDN", "IDN", "IDN", "IDN", "ID...
## $ NAME_0    <chr> "Indonesia", "Indonesia", "Indonesia", "Indonesia", ...
## $ GID_1     <chr> "IDN.1_1", "IDN.1_1", "IDN.1_1", "IDN.1_1", "IDN.1_1...
## $ NAME_1    <chr> "Aceh", "Aceh", "Aceh", "Aceh", "Aceh", "Aceh", "Ace...
## $ NL_NAME_1 <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", ...
## $ GID_2     <chr> "IDN.1.2_1", "IDN.1.1_1", "IDN.1.3_1", "IDN.1.4_1", ...
## $ NAME_2    <chr> "Aceh Barat", "Aceh Barat Daya", "Aceh Besar", "Aceh...
## $ VARNAME_2 <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", ...
## $ NL_NAME_2 <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", ...
## $ TYPE_2    <chr> "Kabupaten", "Kabupaten", "Kabupaten", "Kabupaten", ...
## $ ENGTYPE_2 <chr> "Regency", "Regency", "Regency", "Regency", "Regency...
## $ CC_2      <chr> "1107", "1112", "1108", "1116", "1103", "1102", "111...
## $ HASC_2    <chr> "ID.AC.AB", "ID.AC.AD", "ID.AC.AR", "ID.AC.AJ", "ID....

This map data was downloaded from GADM.com and preprocessed at Mapshaper.org.

Data Preparation


After loading data. I do filtering in NAME_1 column as Jawa Timur and select some important column.

jatim_json_mod <- sf::st_as_sf(jatim_json)

jatim_json_mod <- 
  jatim_json_mod %>% 
  filter(NAME_1 == "Jawa Timur") %>%
  select(CC_2, NAME_2, TYPE_2, geometry) %>%
  rename("Kode" = CC_2) %>%
  mutate(Kode = as.numeric(Kode))

glimpse(jatim_json_mod)
## Observations: 38
## Variables: 4
## $ Kode     <dbl> 3526, 3510, 3579, 3505, 3522, 3511, 3525, 3509, 3517,...
## $ NAME_2   <chr> "Bangkalan", "Banyuwangi", "Batu", "Blitar", "Bojoneg...
## $ TYPE_2   <chr> "Kabupaten", "Kabupaten", "Kota", "Kabupaten", "Kabup...
## $ geometry <MULTIPOLYGON [°]> MULTIPOLYGON (((113.1245 -6..., MULTIPOL...

After that, the data is converted to type sf and data frame. Then do the filtering of East Java province and discard unneeded columns.

Load HDI East Java (Jawa Timur) Data


After finishing modifying the data folder. Furthermore, load HDI data of East Java province. This data is sourced from the BPS website which was downloaded on Thursday, December 5, 2018.

# Data IPM Jatim
jatim_ipm <- read_excel("metode_baru.xlsx")
jatim_ipm <- 
  jatim_ipm %>%
  filter(Kode %in% jatim_json_mod$Kode) %>%
  mutate(Kode = as.numeric(Kode))

glimpse(jatim_ipm)
## Observations: 38
## Variables: 3
## $ Kode       <dbl> 3501, 3502, 3503, 3504, 3505, 3506, 3507, 3508, 350...
## $ `Kab/Kota` <chr> "Pacitan", "Ponorogo", "Trenggalek", "Tulungagung",...
## $ IPM        <dbl> 67.33, 69.91, 68.71, 71.99, 69.93, 71.07, 69.40, 64...
class(jatim_ipm)
## [1] "tbl_df"     "tbl"        "data.frame"

After loading the data, then do filter based on the “Kode” of the data map to choose a specific city.

Merge Map Data and HDI Data.


After HDI data and Base Map data ready. I need to merge as same data frame by Kode column.

# Merge Data
map_jatim_ipm <- merge(jatim_json_mod, jatim_ipm, id = "Kode")
glimpse(map_jatim_ipm)
## Observations: 38
## Variables: 6
## $ Kode       <dbl> 3501, 3502, 3503, 3504, 3505, 3506, 3507, 3508, 350...
## $ NAME_2     <chr> "Pacitan", "Ponorogo", "Trenggalek", "Tulungagung",...
## $ TYPE_2     <chr> "Kabupaten", "Kabupaten", "Kabupaten", "Kabupaten",...
## $ `Kab/Kota` <chr> "Pacitan", "Ponorogo", "Trenggalek", "Tulungagung",...
## $ IPM        <dbl> 67.33, 69.91, 68.71, 71.99, 69.93, 71.07, 69.40, 64...
## $ geometry   <MULTIPOLYGON [°]> MULTIPOLYGON (((111.3904 -8..., MULTIP...
class(map_jatim_ipm)
## [1] "sf"         "data.frame"

After merge data, we are ready to map HDI East Java Province in 2018 using leaflet.

Interactive map


# Mapping
mybins <- c(0,60,70,80,100)
pal <- colorBin("viridis", domain = map_jatim_ipm$IPM, bins = mybins)

# Hover Text
mytext <- paste(
  map_jatim_ipm$TYPE_2, map_jatim_ipm$NAME_2,"<br/>", 
  "Indeks Pembangunan Manusia:", map_jatim_ipm$IPM, 
  sep=" ") %>%
  lapply(htmltools::HTML)

leaflet(map_jatim_ipm) %>% 
  addTiles() %>% 
  addPolygons(fillColor = ~pal(IPM),
              fillOpacity = 0.9,
              stroke = TRUE,
              weight = 1,
              opacity = 1,
              color = "black",
              label =  mytext) %>%
  addLegend(pal=pal, values=~IPM, 
            opacity=0.9, title = "IPM :", 
            position = "bottomleft" )

Thank You

Amri Rohman
Sidoarjo, East Java, ID.