I'm trying to narrow down my postal code table and limit the number or rows to 1 per postal code. I've not had a problem with Canada and the USA. However with Great Britain the data from GeoNames has several location names per posta code in some areas.

For instance, ZE2 in Scotland has 162 locations within it, most have the same lat & lon. Apparently it's one of the postal codes for the Shetland Isles.

How do I find the major location/town within a given postal code? I've tried some sites like http://www.postcodearea.co.uk/postaltowns/shetland-isles/ze2/ but they don't have that sort of information. Where can I find that sort of information?

I'm not building a geolocation map of great detail. This is for a hobby site to help people find others within a reasonable distance.

2 Answers 2


Shetland Postcodes are quiet rural so cover a large area and other Islands

http://www.doogal.co.uk/UKPostcodes.php?Search=ZE2 Lots of points with the same postcode sector.

enter image description here

ZE2 is a multi-part polygon with a hole (donut) So the Centroid is going to be offsetted by the western islands.

You will need to go to the full postcode for more accurate locations


  • Except I asked about single major locations.
    – Maelish
    Jun 24, 2014 at 16:57

How would you define and determine major? How did you solve the problem with US zips? There are plenty of single zip codes that cover multiple towns or large rural areas.

In your example, it appears that Lerwick is the primary population center and has sufficient people to justify its own post code district. Looks like the airport/surrounding region/town also gets one. But the entire rest of the isles all share a single post code district for all population centers of any size.

On GeoNames you can filter down to just the P or PPL tags to get populated locations (44 in this case instead of 162 total locations), but then you'll have to come up with a criteria to select one (population?) and a way to query that. Or you could just call ZE1 Lerwick and ZE2 Shetland Isles, using the region name rather than a specific locale. For that matter you could just use Shetland Isles for all ZE entries.

You may want to refer to the Wikipedia entry on UK post code areas, and the Subdivision links there to post towns and postcode districts.

  • Thanks. It was easy to find the major population center in the USA because most of the zip code data available for download already has that factored in. But I'm beginning to think I'll have to rewrite everything to make it work.
    – Maelish
    Jun 25, 2014 at 16:43
  • You might be better off considering using the Local Government geography for your approach. UK postcodes are either too broad (postal towns, for example overlap major areas) or too fine grained. The Office for National Statistics provides Local Government amalgamated data. Jun 28, 2015 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.