In this assignment we will map all world heritage sites registered with the UNESCO until the date of the creation of this page. The data is downloaded from the UNESCO official website https://whc.unesco.org/en/list/xls/?2018 on Oct.8th 2018. The map is created listing the sites, categorized as Cultural, Natural or Mixed. As you zoom in on different regions, you see all locations with its name and a brief description to help tourists locate them easily.
let’s first load packages:
library(leaflet)
library(readxl)
After you download the data, let’s read it into R and read it:
setwd("~/DataProducts/1")
whc_sites_2018 <- read_excel("~/DataProducts/1/whc-sites-2018.xls")
summary(whc_sites_2018)
## unique_number id_no rev_bis name_en
## Min. : 4.0 Min. : 1.0 Length:1092 Length:1092
## 1st Qu.: 616.5 1st Qu.: 397.2 Class :character Class :character
## Median :1092.5 Median : 788.5 Mode :character Mode :character
## Mean :1140.6 Mean : 784.3
## 3rd Qu.:1724.2 3rd Qu.:1160.2
## Max. :2319.0 Max. :1575.0
##
## name_fr short_description_en short_description_fr
## Length:1092 Length:1092 Length:1092
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
##
## justification_en justification_fr date_inscribed secondary_dates
## Length:1092 Length:1092 Min. :1978 Length:1092
## Class :character Class :character 1st Qu.:1987 Class :character
## Mode :character Mode :character Median :1997 Mode :character
## Mean :1997
## 3rd Qu.:2006
## Max. :2018
##
## danger_list longitude latitude area_hectares
## Length:1092 Min. :-179.715 Min. :-54.59 Min. : 0
## Class :character 1st Qu.: -3.255 1st Qu.: 17.18 1st Qu.: 9
## Mode :character Median : 16.314 Median : 36.08 Median : 181
## Mean : 19.923 Mean : 28.93 Mean : 279795
## 3rd Qu.: 49.165 3rd Qu.: 45.70 3rd Qu.: 13552
## Max. : 178.835 Max. : 71.19 Max. :40825000
## NA's :15
## C1 C2 C3 C4
## Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.0000
## 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000
## Median :0.0000 Median :0.0000 Median :0.0000 Median :1.0000
## Mean :0.2317 Mean :0.4038 Mean :0.4148 Mean :0.5339
## 3rd Qu.:0.0000 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1.0000 Max. :1.0000 Max. :1.0000 Max. :1.0000
##
## C5 C6 N7 N8
## Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.00000
## 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.00000
## Median :0.0000 Median :0.0000 Median :0.0000 Median :0.00000
## Mean :0.1383 Mean :0.2207 Mean :0.1328 Mean :0.08425
## 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.:0.00000
## Max. :1.0000 Max. :1.0000 Max. :1.0000 Max. :1.00000
##
## N9 N10 criteria_txt category
## Min. :0.0000 Min. :0.0000 Length:1092 Length:1092
## 1st Qu.:0.0000 1st Qu.:0.0000 Class :character Class :character
## Median :0.0000 Median :0.0000 Mode :character Mode :character
## Mean :0.1154 Mean :0.1401
## 3rd Qu.:0.0000 3rd Qu.:0.0000
## Max. :1.0000 Max. :1.0000
##
## category_short states_name_en states_name_fr
## Length:1092 Length:1092 Length:1092
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
##
## region_en region_fr iso_code
## Length:1092 Length:1092 Length:1092
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
##
## udnp_code transboundary
## Length:1092 Min. :0.00000
## Class :character 1st Qu.:0.00000
## Mode :character Median :0.00000
## Mean :0.03388
## 3rd Qu.:0.00000
## Max. :1.00000
##
Not all data is useful for our job. How about we create a new dataset -let’s call it sites- with the data we are going to use.
sites <- data.frame(latitude = c(whc_sites_2018$latitude), longitude = c(whc_sites_2018$longitude), name = c(whc_sites_2018$name_en), category = c(whc_sites_2018$category), desc = c(whc_sites_2018$short_description_en))
Now we are ready to create the map.
#We use awesome icons to create ones colored according to category
icons <- awesomeIcons(icon ="street-view", library = "fa", markerColor = sites$category, iconColor = "black")
#Now everything is ready let's create a map, cluster its numerous data points together, and color them.
# You can view the name of the site by hovering your mouse cursor over it; you can read its description by clicking the icon:
sites %>% leaflet() %>% addTiles() %>% addAwesomeMarkers(icon = icons, label = sites$name,labelOptions = labelOptions(opacity = 0.8, textsize = "14px", style = list(color = "red", 'font-style' = "italic")), clusterOptions = markerClusterOptions(maxClusterRadius = 50), popup = sites$desc)
## Assuming "longitude" and "latitude" are longitude and latitude, respectively