Hello! This page is for showcasing the power of leaflet package in R . This document displays an interactive map of the major attractions in Singapore .

To start with - Sentosa Island .

It is a small island which stands as a major vacation destination for nearly 2 million tourists from all over the world . It was first conceptualized as a resort in 1976 and since then has housed many 5 star hotels , entertainment areas , museum , shopping areas ,beach line , etc

library(leaflet)
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 3.2.5
## Loading tidyverse: ggplot2
## Loading tidyverse: tibble
## Loading tidyverse: tidyr
## Loading tidyverse: readr
## Loading tidyverse: purrr
## Loading tidyverse: dplyr
## Warning: package 'ggplot2' was built under R version 3.2.5
## Warning: package 'tibble' was built under R version 3.2.5
## Warning: package 'tidyr' was built under R version 3.2.5
## Warning: package 'readr' was built under R version 3.2.5
## Warning: package 'purrr' was built under R version 3.2.5
## Warning: package 'dplyr' was built under R version 3.2.5
## Conflicts with tidy packages ----------------------------------------------
## filter(): dplyr, stats
## lag():    dplyr, stats
## Add the marker for Sentosa Island . 

my_map <- leaflet() %>% addTiles () %>% addMarkers(lat = 1.25011 , lng = 103.83093 , popup ="Sentosa Island")

my_map

We can have a look at the other important tourist locations in Singapore . This display helps in understanding how the various attractions are spread out .

df <- data.frame(lat = c(1.25011,1.28544, 1.318707, 1.282375, 1.4043, 1.4022, 1.4029 , 1.2868 , 1.3332, 1.2893 ) , long =c(103.83093 ,103.859590, 103.706442 , 103.864273 , 103.7930 , 103.7881 , 103.7917, 103.8545, 103.7362 , 103.8631) , popup = c("Sentosa Island", "Marina Bay Sands " , "Jurong Bird Park","Gardens By the Bay", "Singapore Zoo" , "Night Safari", "River Safari", "Merlion Park","Science Center", "Singapore Flyer") )

my_map <- leaflet() %>% addTiles() %>% addMarkers(data = df , lng = ~long , lat = ~lat , popup = df$popup)   

my_map

Can we cluster the attractions ? Yes ! This will help the tourists in planning their travel and logistics .

my_map %>% leaflet() %>% addTiles() %>% addCircleMarkers(data = df , lng = ~long , lat = ~lat , radius = 5 , clusterOptions = markerClusterOptions())

We can make the map more expressive by adding Icons .

sgIcon <- leaflet::makeIcon(iconUrl = "http://img.freeflagicons.com/thumb/speech_bubble_icon/singapore/singapore_640.png", iconWidth = 41*225/240 , iconHeight = 41, iconAnchorX = 31*215/230/2, iconAnchorY = 16 )
my_map <- leaflet() %>% addTiles() %>% addMarkers(data = df , lng = ~long , lat = ~lat , popup = df$popup , icon = sgIcon)  

my_map

This was just a glimpse of the capability of leaflet in R . By incorporating other functions in leaflet library we can provide more in depth visualization of the maps .

This is a very powerful tool , to analyse and display various events such as volcanic erruptions , earthquake prone segments , spread of infectious diseases /epidemics , availability of natural resources , social media analysis by location etc

Thank you!