Thailand gross provincial product (GPP) 2013
suppressPackageStartupMessages(library(rgdal))
suppressPackageStartupMessages(library(leaflet))
url <- "thailand-provinces.geojson"
file <- "thai_gpp.csv"
thaiProvinces <- readOGR(dsn = url, encoding = "UTF-8")
## OGR data source with driver: GeoJSON
## Source: "thailand-provinces.geojson", layer: "OGRGeoJSON"
## with 78 features
## It has 3 fields
filterOutProvinces <- c("Phatthalung (Songkhla Lake)","Songkhla (Songkhla Lake)")
thaiProvinces <- thaiProvinces[!(thaiProvinces$NAME_1 %in% filterOutProvinces),]
thaiGPP <- read.table(file,header = TRUE,sep = ",")
map1 <- leaflet(thaiProvinces) %>% addTiles()
pal1 <-colorNumeric("Blues", domain = thaiGPP$GPP_Million_Dollar)
popup1 <- paste(as.character(thaiProvinces$NAME_1),as.character(thaiGPP$GPP_Million_Dollar),"Million $US")
map1 %>%
addPolygons(stroke = FALSE, smoothFactor = 0.2, fillOpacity = 1,
color = ~pal1(thaiGPP$GPP_Million_Dollar), popup = popup1) %>%
addLegend("bottomright", pal = pal1, values = ~thaiGPP$GPP_Million_Dollar,
title = "Est. Thailand GPP 2013 (Million $US)",
opacity = 1)