I have been bought up in what i love to say the “The Queen of fairyLand”, s small town Siliguri.
Siliguri is a city which spans across the Darjeeling and Jalpaiguri districts in the Indian state of West Bengal. The city is located on the banks of the Mahananda River and the foothills of the Himalayas.
You can find more information about this city in this Link
I’ve tried to create a map of some of the interesting places to visit in Siliguri
Instal Packages
library(plyr)
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.3.3
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:plyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(XML)
## Warning: package 'XML' was built under R version 3.3.3
library(leaflet)
## Warning: package 'leaflet' was built under R version 3.3.3
List some interesting Places
cities <- c("Jaldapara National Park, Siliguri", "ISKCON Temple, Siliguri", "Salugara Monastery, Siliguri",
"Vega Circle Mall, Siliguri", "Hong kong market, Siliguri", "North Bengal Science Centre, Siliguri",
"Bengal Safari North Bengal Wild Animals Park, Siliguri")
As it is not always possible to load latitude and longitude data, lets fetch the geo location data from google maps api
funcLatLong <- function(place)
{
googleURL <- sprintf('http://maps.google.com/maps/api/geocode/xml?sensor=false&address=%s', place)
doc <- xmlToList(googleURL)
data.frame(Place=place,
Latitude=as.numeric(doc$result$geometry$location$lat),
Longitude=as.numeric(doc$result$geometry$location$lng),
stringsAsFactors=FALSE)
}
Call the above function on the character vector cities.
places <- adply(cities,1,funcLatLong)
str(places)
## 'data.frame': 7 obs. of 4 variables:
## $ X1 : Factor w/ 7 levels "1","2","3","4",..: 1 2 3 4 5 6 7
## $ Place : chr "Jaldapara National Park, Siliguri" "ISKCON Temple, Siliguri" "Salugara Monastery, Siliguri" "Vega Circle Mall, Siliguri" ...
## $ Latitude : num 26.7 26.7 26.8 26.8 26.7 ...
## $ Longitude: num 89.3 88.4 88.4 88.4 88.4 ...
Prepeare a dataframe with cities, lat , long to be used in the map
df = data.frame(places, stringsAsFactors = F)
str(df)
## 'data.frame': 7 obs. of 4 variables:
## $ X1 : Factor w/ 7 levels "1","2","3","4",..: 1 2 3 4 5 6 7
## $ Place : chr "Jaldapara National Park, Siliguri" "ISKCON Temple, Siliguri" "Salugara Monastery, Siliguri" "Vega Circle Mall, Siliguri" ...
## $ Latitude : num 26.7 26.7 26.8 26.8 26.7 ...
## $ Longitude: num 89.3 88.4 88.4 88.4 88.4 ...
Create the Map using leaflet
mapofSiliguri = leaflet() %>%
setView(lng = mean(df$Longitude), lat = mean(df$Latitude), zoom = 9) %>%
addTiles() %>%
addMarkers(data=df, ~Longitude, ~Latitude, popup = paste(cities))
mapofSiliguri