Koketso Mangwale
4 min readApr 1, 2023

Visualizing Hong Kong’s Landslides

Hong Kong has the Enhanced Natural Terrain Landslide Inventory (ENTLI) which is a historical record of more than 100 000 landslide occurrences from 1924 to 2019 from aerial photographs taken of hillsides and slopes. The locations of identified landslides and their associated data can be downloaded from the city’s Public Sector Information portal, https://data.gov.hk/en.

Data Description

The data is free to download and use, so I decided to use geopandas and the Folium library so I can easily explore and visualize the geospatial data.

import geopandas as gpd

#read the file into a geodataframe
landslide_data = gpd.read_file('ENTLI_Up_to_Year_2019.gdb')
landslide_data.head()

Geopandas generates a geometry point representing the landslide crown from the geo database read.

Extract latitudes and longitudes

The original projection of the data is EPSG 2326. So, I convert the data to the standard coordinate system for earth. So the geometry points are now in latitudes and longitudes instead of the northing and easting points.

#convert crs to EPSG 4326
landslide_4326 = landslide_data.to_crs(epsg = 4326)
landslide_4326.head()

Thereafter, I extract the latitudes and longitude into separate columns from the geometry column.

#insert latitude and longitude columns
landslide_4326['latitude'] = landslide_4326.geometry.y
landslide_4326['longitude'] = landslide_4326.geometry.x

Visualizations

I decided to use Folium to plot geo visualizations that serve the purpose of indicating the distribution of landslides on natural terrain.

First I initiate Folium map with the coordinates for Hong Kong to create a base map and then I create a MarkerCluster(), HeapMapWithTime() and Circle().

import folium
from folium import Circle, Marker
from folium.plugins import MarkerCluster, HeatMapWithTime

Landslide Occurrence (1924–2019)

Using the latitude and longitude columns I create a marker and then add it to the base map.

#create a base Folium map using Hong Kong coordinates
map_1 = folium.Map(location=[22.396428, 114.109497],
tiles='cartodbpositron', zoom_start=10.5)

#initiate the MarkerCluster
mc = MarkerCluster()

#create the Markers and add them to the base map
for idx, row in landslide_4326.iterrows():
mc.add_child(Marker([row.latitude, row.longitude]))

map_1.add_child(mc)
A MarkerCluster with individual Markers as you zoom in

Landslide Occurrence Heat Map Time-lapse (1999–2019)

Now I want to display a heat map of landslide occurance per year for a 20 year period. The HeapMapWithTime plugin takes a list of lists and adds them to the maps according to the index.

This requires listing the coordinates and organizing them per year. The years from column ‘YEAR_1’ will also be listed as string indexes.

weight_list = []

#create list of list of latitides and longitudes
for _, data in landslide_4326.groupby('YEAR_1'):
weight_list.append([[row2['latitude'],
row2['longitude']] for _, row2 in data.iterrows()])
#list of years
year_index = list(landslide_4326.YEAR_1.sort_values().astype('str').unique())

#create a base Folium map using Hong Kong coordinates
map_2 = folium.Map(location=[22.396428, 114.109497],
tiles='cartodbpositron',
zoom_start=10.5)

#add a heatmap to the base map
HeatMapWithTime(weight_list,
index = year_index,
min_opacity=0.1,
auto_play = True).add_to(map_2)

map_2
Snapshot of HeapMapWithTime of the 2008 Landslides
Snapshot of HeapMapWithTime of the 2018 Landslides

Conclusion

There is a large number of data to plot from the inventory which leads to overlapping points. But with Folium, as seen in the foregoing, the maps are interactive making it possible to zoom in and out and assess the density of landslides.

A map does not just chart, it unlocks and formulates meaning; it forms bridges between here and there, between disparate ideas that we did not know were previously connected. — Reif Larsen

References

User Guide — GeoPandas 0.12.2+0.gefcb367.dirty documentation

Tutorial 1.2 — Spatial analysis with Python (sustainability-gis.readthedocs.io)

Koketso Mangwale

An aspiring data analyst documenting my progress | Data Analysis | Python | SQL | Problem Solving