fungyip / MTR

This repository is created to visualise the development of MTR stations in Hong Kong since 1910 based on the tables available on Wiki https://en.wikipedia.org/wiki/List_of_MTR_stations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Title Author Date Analytics
MTR Metro Development Over Time 港鐵路線圖
Fung YIP
04 Feb 2017
Web Scraping GIS Data Viz
XML
Geocoding
Gif

Introduction

This repository is created to visualise the development of MTR stations in Hong Kong since 1910 based on the tables available on Wiki https://en.wikipedia.org/wiki/List_of_MTR_stations.

Data Visualisation

Result

The first railway was to connect between Mainland China and Hong Kong and then there was a development of Kowloon side area in the late 70s. Hong Kong Island witnessed the expansion of MTR stations later in the 80s.

Development of MTR Stations over time

      MTR Stations

2. Problem Solving

####2.1 Using Web Scraping technique and Geocoding in order to identify station locations.

Wiki https://en.wikipedia.org/wiki/List_of_MTR_stations


library(tidyverse)
library(ggmap)
library(gganimate)

#Data Import
mtr <- read_csv("./DataIn/HK_POI_MTR.csv")  

#MTR Adddress Geocoding
names(mtr)
head(mtr)
mtr_address<-mtr$Address
x<-geocode(mtr_address)
mydata<-cbind(mtr,x)

write_csv(mydata,"./DataIn/HK_POI_MTR_geo.csv")
mydata <- read_csv("./DataIn/HK_POI_MTR_geo.csv")

####2.2 Data Viz

#Get Hong Kong Map
HK_map_color = get_googlemap(center = "Hong Kong", maptype = "roadmap",
                             zoom = 11, size = c(640, 420), color = "color")

HK_map_bw = get_googlemap(center = "Hong Kong", maptype = "roadmap",
                          zoom = 11, size = c(640, 420), color = "bw")

MTROverTime = function(city_map){
  ggmap(city_map, extent = "device") +
    geom_point(data = mydata,
               aes(x = lon, y = lat, frame = Opened, cumulative = TRUE),
               color = "blue", size = 3) 
}

plot <- MTROverTime(HK_map_color)
plot
gganimate(plot,"./DataOut/MTRMapOverTime.gif")

About

This repository is created to visualise the development of MTR stations in Hong Kong since 1910 based on the tables available on Wiki https://en.wikipedia.org/wiki/List_of_MTR_stations


Languages

Language:R 100.0%