What colour is your postal code?

The idea behind this project was simple:

  1. In Singapore all postal codes are six digits.

  2. Six digits can also correspond to a colour (in hex triplets).

  3. If every postal code was converted to its hex colour, what would a map of Singapore look like?

So, firstly I had to get every postal code in Singapore. After geocoding all of Singapore’s HDBs, I was hopeful there would be a database of every postal code floating around on data.gov.sg, but it appears not.

To get around this problem I wrote a Python script to list every number from zero to 999,999 with the word ‘Singapore’ at the beginning. Any number that was smaller than six digits I put zeros in front like ‘Singapore 018956’. I took this as my dataset and opened it up in Tableau.

Tableau has an amazing feature where marking data as geographical generates real latitudes and longitudes. Just like that, my Python list of numbers became postal codes. Of course, many of the numbers didn’t correspond to actual addresses, but Tableau was able to find 130,397 that did. I’m not sure if this is every postal code in Singapore, but if it’s not, it’s pretty close.

Next I wanted to what each postcode looked like as a hex colour. For this I went back into Python and used a feature called graphing library called ‘plotly’.

import pandas as pd
import plotly.express as px

df = pd.read_excel('all_postcodes.xlsx', 'all_postcodes')

fig = px.scatter_mapbox(df, lat="Latitude", lon="Longitude", color_discrete_sequence=[df["code"]], 
                        hover_data={"Latitude":False, "Longitude":False, "Postal code":True}, 
                        hover_name="Color", zoom=9, height=300)

fig.update_layout(mapbox_style="open-street-map")
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()

I adapted code from an app called Name That Color to find the closest colour name for each postcode.

The most common colour was Forest Green with 4917 matches. The next six most common were all shades of green too. It seems with this project Singapore is more garden city than little red dot.

Obviously looking at postcodes and colour in this way has no basis in reality, but it was fun to find coincidences in the postcodes and their corresponding colours. Like the oberservation deck at Marina Bay Sands being called Observatory. Or the tiny cluster of red surrounded by green in Lim Chu Kang being called Lone Star. Or the Ocean Green colour all along East Coast Park.

Explore the map below or click here to find what colour your postcode is. The map has over 100,000 data points so viewing on desktop is definitely recommended.

Previous
Previous

The 100 oldest companies in the world

Next
Next

Geocoding every HDB in Singapore