Skip to content
DewPoint-AnalyticsPublic

About

Interactive hex atlas of Malaysia from DOSM open data: income, poverty, labour, GDP, crops and ports for all 160 districts, styled as a strategy game. Inspired by Karpathy's USACiv.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Hexlah

Malaysia rolled a strategy map. DOSM brought the stats.

Open the atlas ↗ · Explore the map · Behind the build

hexlah-trailer-readme.mp4

🗺️ Open the live atlas ↗

What if you could explore Malaysia’s economy like a strategy map? Hexlah brings that idea to life using Andrej Karpathy’s original USACiv renderer and real data from the Department of Statistics Malaysia (DOSM). Pan from Peninsular Malaysia to Sabah and Sarawak, hover any hex to see its district, and switch lenses to watch the country change colour, from household income and poverty to population density and the economy.

1,284 Malaysian hexes · 10 km tile radius · 160 districts · 13 states and 3 federal territories · 23 data lenses · 14 seaports

Explore the map

Each link opens the atlas at that view.

Try this What you’ll see
Household income Median monthly household income for every district. Hulu Langat is the highest at RM 11,404; Bukit Mabong in Sarawak is the lowest at RM 2,589 (HIES 2024).
Poverty in Sabah Half of all households in Pitas live below the poverty line. Hover a hex to see its district.
Gold per person In the atlas, GDP is called Gold. Bintulu’s LNG industry makes it the richest district per head.
Density in Kuala Lumpur About 8,500 residents per km², the most crowded hexes in the country.
Ports Harbour medallions mark all 14 port authorities, sized by cargo. Hover Port Klang: 249 million tonnes and 14.6 million TEU in 2024. Press R to hide them.
Non-citizens In Kinabatangan, 73% of residents are not Malaysian citizens.
Durian Raub, home of Musang King, harvested 103,000 tonnes of durian in 2024, the most of any district.
Sabah Its population, real GDP, growth, and GDP rank among the 16 regions.
Putrajaya The federal territory, small enough to fit in a single hex.

Drag to pan, scroll to zoom, and use the minimap to jump across the country. Press / to search or L to cycle lenses.

The 23 lenses

Group Lenses
People Density · Population growth (2020–2025) · Under 15 · Aged 65+ · Non-citizens
Prosperity Household income · Poverty · Inequality (Gini)
Work Unemployment · Labour force participation
Economy Gold per person · Manufacturing · Agriculture · Mining · Services
Living Piped water
Food Coconut · Durian · Tea · Pineapple (tonnes harvested per km², 2024)
States State population · State GDP · State GDP growth

Ports. Harbour markers show every port authority in the Ministry of Transport's 2024 cargo table, from Port Klang and Tanjung Pelepas to Teluk Ewa on Langkawi. Hover one for its freight tonnes and container volume. A tourist-destination marker on Langkawi shows its 2.81 million visitor arrivals in 2023 (LADA).

From tea hills to mountain clouds

Every photo is a door: click one to fly there in the atlas.

City of lights

Kuala Lumpur skyline at dusk with the Petronas Twin Towers lit up
Kuala Lumpur at dusk
“Every lit window is a line in the ledger; together they read RM 265 billion.”
opens Density: about 8,500 people per km²
Petronas Twin Towers seen from directly above, with KLCC Park below
Petronas Twin Towers
“Seen from above, ambition is just geometry with a view.”
opens Gold per person over the capital
Pink-domed Putra Mosque beside Putrajaya Lake
Putra Mosque, Putrajaya
“A capital built for government, mirrored in a lake it made for itself.”
flies to Putrajaya, small enough for one hex

Wild Malaysia

Clouds below a viewpoint on Mount Kinabalu in Sabah
Mount Kinabalu, Sabah
“Mountains keep their records in stone; we only borrowed the elevation.”
flies to the snow-capped hexes of Sabah
A Rafflesia flower in bloom on the rainforest floor
Rafflesia, Sarawak
“The rainforest’s rarest bloom: here for days, remembered for a lifetime.”
flies to Gunung Gading, Sarawak’s Rafflesia park
Layered mountain ranges viewed from Mount Murud in Sarawak
Mount Murud, Sarawak
“On Sarawak’s roof, every border dissolves into cloud.”
flies to the Borneo highlands

Highlands and islands

Sunrise over rolling tea rows in the Cameron Highlands, with mist in the valley
Cameron Highlands, Pahang
“Ninety-five percent of a nation’s tea, grown in the mist.”
opens the Tea lens
The curved Langkawi Sky Bridge above the rainforest and the Andaman Sea
Sky Bridge, Langkawi
“2.8 million visitors a year, and the horizon still has room for one more.”
opens Services: 80% of Langkawi’s output · hover the island for visitors

The table

A vendor among baskets of chillies, cucumbers, mushrooms and greens at a Malaysian wet market
The wet market
“A market is an economy you can smell: every basket a district’s harvest.”
opens Agriculture over the east coast
A rattan tray of colourful Malay kuih: onde-onde, kuih dadar, kuih lapis and seri muka
Kuih
“Coconut, pandan, rice flour: three crops, a hundred colours.”
opens the Coconut lens
A Malaysian spread: nasi lemak, nasi kunyit, laksa, curry mee and more
Nasi lemak and friends
“Read the table and you read the land: rice, coconut, chilli and sea.”
opens Coconut, the santan that makes it lemak

How the atlas is built

  1. Join the statistics. Python loads the DOSM CSVs into SQLite. SQL joins state GDP and population and calculates growth.
  2. Build the hex grid. The pipeline projects boundaries into a Lambert cylindrical equal-area coordinate system. Land tiles are assigned to states by polygon overlap, with a maximum-overlap rule so that small regions still get a tile.
  3. Add the districts. Each hex is overlaid on the 160 district boundaries. A hex that straddles districts blends their figures, weighted by the residents each district contributes to it. Density spreads each district's people evenly over its land.
  4. Place the ports. Each port in inputs/mot_ports_2024.csv goes on the nearest hex of its state and is written to resources.json, which the renderer draws as markers.
  5. Render in the browser. The build writes JSON into docs/data/. Karpathy’s Canvas renderer reads those files and powers the map, minimap, search, tooltips, and lenses.

The headline GDP sums the 16 regions and excludes DOSM’s geographically unallocated Supra GDP. City banners use Natural Earth label estimates (POP_MAX).

Data notes. Six newer districts are not yet on the boundary map, so each is folded into the district it was carved from: Membakut into Beaufort, Gedong and Sebuyau into Simunjan, Lingga and Pantu into Sri Aman, and Siburan into Serian. Because Membakut took land from both Beaufort and Papar, their population growth is shown pooled. Perlis and the federal territories take their 2024 income and poverty figures from DOSM’s state tables. Their 2024 inequality and labour figures are not in the district tables, so those hexes show no data on those lenses. District GDP is the 2020 release, the latest published at district level.

Advisors, the Explorer, the City View, airports, and roads are future work. Malaysia publishes no state-to-state freight flow table like the US one behind Karpathy's trade routes, so the ports stand in for trade.

Path Role
build.py Projects boundaries, assigns hexes, and builds JSON
districts.py Assigns hexes to districts and builds the district lenses
geography.py Elevation, rivers, and populated places
inputs/tourism.csv Official visitor arrivals for tourist destinations (Langkawi, from LADA)
inputs/mot_ports_2024.csv 2024 cargo and container throughput for the 14 port authorities, with terminal locations
metrics.sql Joins the DOSM state datasets and computes regional measures
inputs/ Source CSVs, boundary files, and elevation tiles
docs/ Deployable site with HTML, CSS, JavaScript, and data
LICENSE All rights reserved for DewPoint Analytics work; the original USACiv renderer stays MIT

Run, rebuild, or publish

Preview the prebuilt atlas from the repository root:

python -m http.server 8000 --directory docs

Open localhost:8000. To rebuild the data:

python -m pip install -r requirements.txt
python build.py

If an elevation tile is missing from inputs/terrarium/, the build says which one and where to download it. As long as the grid hasn't changed, it reuses the elevation already in docs/data/world.json.

For GitHub Pages, publish from main → /docs. Keep docs/index.html and its sibling folders css/, js/, and data/ together.

Sources and credits

Photography credits

About

Interactive hex atlas of Malaysia from DOSM open data: income, poverty, labour, GDP, crops and ports for all 160 districts, styled as a strategy game. Inspired by Karpathy's USACiv.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages