Data Exploratory: Part I

Population at a glance, rainfall, temperature

Available Dataset & Sources

Code
# The imports
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import requests
import geopandas as gpd
import hvplot.pandas
import rasterio as rio
import rioxarray
import xarray as xr
import hvplot.xarray
import panel as pn
import osmnx as ox
from shapely.geometry import Point

# Make sure plots show up in JupyterLab!
%matplotlib inline
Code
pd.options.display.max_columns = 999

Data Exploratory

1. Hong Kong Population

Initially, we examined the population density across all 18 districts of Hong Kong. This analysis was based on the 2021 Census data obtained from the ESRI China data portal. The population density was calculated by dividing the total population of each district by its respective area.

Code
# url for population data
pop_url = (
    "https://services3.arcgis.com/6j1KwZfY2fZrfNMR/arcgis/rest/services/Hong_Kong_Population_Density_2021/FeatureServer/0/query?outFields=*&where=1%3D1&f=geojson"
)
pop_raw = gpd.read_file(pop_url)
Code
district_url = (
    'https://services3.arcgis.com/6j1KwZfY2fZrfNMR/arcgis/rest/services/Hong_Kong_18_Districts/FeatureServer/0/query?outFields=*&where=1%3D1&f=geojson'
)
hk_limit = gpd.read_file(district_url)
Code
pop_raw.hvplot(
    c="Population_Density",
    frame_width=600,
    frame_height=600, 
    alpha=0.7,
    geo=True,
    cmap="Oranges",
    hover_cols=["District"],
    tiles="CartoLight"
)

It can be seen that the middle five districts: Kwun Tong, Wong Tai Sin, Kowloon City, Yau Tsim Mong, Sham Shui Po are having the highest population density, where there are various amenities such as museums, parks, extensive infrastructure, restaurants and shopping mall, as well as schools and hospitals. These regions are also called old city in Hong Kong, the opposite to the Hong Kong Island (Central, Wan Chai, and Eastern) where is well known for the city’s financial hub.

2. Hong Kong Rainfall

We aim to next examine the total annual rainfall in the Hong Kong area over the past thirty years. Situated in a region prone to tropical cyclones and substantial rainfall, Hong Kong experiences a predominantly rainy climate. This consistent exposure to heavy precipitation significantly elevates the risks of flooding and inundation.

Code
rain_bar = rain.hvplot.bar(x='Year', y='max_rainfall', rot=90, alpha=0.7, color="aquamarine")
rain_line = rain.hvplot(x='Year', y='max_rainfall')
rain_bar*rain_line

The bar and line chart illustrates that precipitation levels in Hong Kong have remained relatively consistent over time, with occasional spikes attributed to regional extreme weather events. On average, there has not been a significant increase in total annual rainfall in the area.

3. Temperature

We next delve into an overview of the annual temperature trends, offering a concise preliminary examination that will be elaborated upon in the ‘Urban Heat Island’ section. In this analysis, we focus on three key metrics: the annual maximum temperature, minimum temperature, and mean temperature.

Code
temp_url = (
    "https://data.weather.gov.hk/weatherAPI/opendata/opendata.php?dataType=CLMMAXT&rformat=csv&station=HKO"
)
temp_raw = pd.read_csv(temp_url, skiprows=[0,1])
Code
temp_data = temp_new.groupby('Year', dropna=True, as_index=False).agg({
    'temp': ['max', 'min', 'mean']})
Code
# Create a Select widget with options for 'temp_max', 'temp_min', 'temp_mean'
select_widget = pn.widgets.Select(name='Temperature Metric', options=['temp_max', 'temp_min', 'temp_mean'])

# Define a function that creates an hvplot based on the selected metric
def create_temperature_plot(metric):
    return temp_data.hvplot.line(x='Year', y=metric, height=400, width=700, title=f'Yearly Temperature ({metric})', rot=90)

# Bind the plot function to the widget
dynamic_plot = pn.bind(create_temperature_plot, metric=select_widget)

# Create a Panel layout with the widget and the bound plot
layout = pn.Column(select_widget, dynamic_plot)

# If running in a Jupyter notebook, display the Panel layout using:
layout

Analyzing the graph spanning from 1990 to 2023, we observe a clear upward trend in temperatures, indicating a general increase over time. This pattern suggests that Hong Kong is not immune to the effects of global climate change, which appears to be contributing to progressively warmer conditions in the region. Furthermore, the rapid urbanization of Hong Kong is likely exacerbating this warming trend. To understand this phenomenon in greater depth, we will conduct a thorough analysis and evaluation of the Urban Heat Island effect across various regions in Hong Kong.