Malaysia rolled a strategy map. DOSM brought the stats.
Open the atlas ↗ · Explore the map · Behind the build
hexlah-trailer-readme.mp4
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
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.
| 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).
Every photo is a door: click one to fly there in the atlas.
- Join the statistics. Python loads the DOSM CSVs into SQLite. SQL joins state GDP and population and calculates growth.
- 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.
- 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.
- Place the ports. Each port in
inputs/mot_ports_2024.csvgoes on the nearest hex of its state and is written toresources.json, which the renderer draws as markers. - 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 |
Preview the prebuilt atlas from the repository root:
python -m http.server 8000 --directory docsOpen localhost:8000. To rebuild the data:
python -m pip install -r requirements.txt
python build.pyIf 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.
- DOSM state GDP and population, CC BY 4.0. Real GDP by state · Population by state
- DOSM district data, CC BY 4.0. Population by district · Household income · Poverty · Inequality · Labour force · Real GDP by district · Basic amenities · Crop production · Household income by state · Poverty by state
- Seaport cargo and container throughput, Ministry of Transport Malaysia, Transport Statistics Malaysia 2024, Tables 3.1 and 3.5. PDF
- Langkawi visitor arrivals, Langkawi Development Authority (LADA). Statistics
- Malaysia ADM1 and ADM2 boundaries, geoBoundaries and © OpenStreetMap contributors, ODbL 1.0. States · Districts · Licence
- Neighbouring country boundaries, Natural Earth, public domain. Source
- Elevation, Mapzen Terrain Tiles, Terrarium PNG mosaic. AWS Open Data
- Populated places and rivers, Natural Earth, public domain. Populated places · Rivers
- Original USACiv code and procedural art, Andrej Karpathy, MIT. Source archive
Photography credits
- Cameron Highlands sunrise by Josh Kirk. Photo · Unsplash License
- Mount Kinabalu by Lim Kelvin. Photo · CC BY-SA 4.0
- Mount Murud by Wilson Chin. Photo · CC BY-SA 4.0
- Putra Mosque by Htenbos. Photo and public-domain dedication








