How to map UK postcodes

shanil
New Member

Hi,

I’ve pulled through UK postcodes of the data type character varying and in the format ‘LE184NG’

Upon adding to Look ML I notice that there is an existing map_layer_name for UK postcodes. 

However, I am not sure if I’m using this correctly as the map visualisation doesn’t work

  dimension: delivery_postcode {
type: string
map_layer_name: uk_postcode_areas
sql: ${TABLE}.delivery_postcode ;;
hidden: yes
description: "The delivery postcode for each order"
}

Thanks in advance for any help!

0 7 1,647
7 REPLIES 7

It won’t work because you have a postcode but the map only accepts postcode areas, which is a higher level field:

https://en.wikipedia.org/wiki/List_of_postcode_areas_in_the_United_Kingdom

You can create a derivative field postcode_area by extracting the letters at the beginning of the postcode.

shanil
New Member

Ah I see thanks Dawid!

Is there any map visualisations that allow you to look more granular? such as on a district level e.g. WC1 for district, WC for area

There’s no map visualisation out of the box that supports that. You’d have to build it yourself. For example there is a district Shapefile available but you would have to convert it to TopoJSON, load it as custom map, and make sure your data is aligned with the map.

https://www.opendoorlogistics.com/wp-content/uploads/Data/UK-postcode-boundaries-Jan-2015-topojson/D...

ba5e69b4-1286-41a6-b91a-d07f61bfc119.png

shanil
New Member

Got you, thanks Dawid

It won’t work because you have a postcode but the map only accepts postcode areas, which is a higher level field:

https://en.wikipedia.org/wiki/List_of_postcode_areas_in_the_United_Kingdom

You can create a derivative field postcode_area by extracting the letters at the beginning of the postcode.

Dawid - do you think you could help with how to do:

You can create a derivative field postcode_area by extracting the letters at the beginning of the postcode.

I’ve tried but not sure how to do it with BigQuery and Looker

Use the following Regular Expressions:

Area: 

^[a-zA-Z][a-zA-Z]?

District:

^[a-zA-Z]+\d\d?[a-zA-Z]?

Thank you

Top Labels in this Space
Top Solution Authors