City Labels

Ben Doherty
BravoVictorNovember
5 min readApr 11, 2022

A way to generate a lot of unique, but memorable labels. The cities are unique, the countries are just there for context.

There’s a repo with all the code here:

(left) A black sticker, stuck to a Microsoft Surface dock, on a desk. It says “Lyminge, UK” in the bottom left corner in white writing. It has a world map on the rest of the sticker, and a yellow cross over Lyminge. There is also a keyboard in the foreground and some wires in the background. (right) A black sticker, stuck to a desk. It says “Novi Sad, Serbia” in the bottom left corner in white writing. It has a world map on the rest of the sticker, and a yellow cross over the city.

The context

Since going back into the studio after Covid, BVN has had a pretty relaxed approach to where to sit. It’s not exactly hot desking, and it’s not exactly, well, any officially understood way of working. (Yet; maybe it will change soon?) This is a change, and it presents a few opportunities and challenges (not to sound too corporate):

  • 🙂 You can sit wherever you like. If you need an hour of quiet, pick up your laptop and sit somewhere quieter.
  • 😢 You can never find anyone, they might be in the studio, or they might be at home. Are you wasting your time looking? You just don’t know. BVN has movable desks in the Sydney studio.
  • 🙂 If we think of the studio as a place where we do experiments then this is a major opportunity to learn something.
  • 😢 We don’t have a way of recording the results of any experiments we do, so we’re not (yet) able to learn anything beyond some anecdotes.
  • 😢 The Sydney studio has movable desks. This means that when an IT support call comes in “my screen is broken” there’s no way to know which desk someone is talking about.

Taking all those together, there’s a lot we can do (and I’ll link to that once we do it), but the first step is identifying what we’ve got. That means giving each desk and dock an identifying name.

Names are hard. The old favourite of a random hex number e.g. 18b428 is hard to say, hard to type accurately, and hard to remember. Something like X Æ A-12 is hard to say and hard to type. What we need is something easy to say, unique, and memorable. Categories of things are pretty good for that, e.g. bond villains, types of octopus, countries. These are great, but they also suffer from being quite short lists, and if you have a lot of things to label, Blowfelt7 gets you back to where you started.

Donald Pleasence as Ernst Stavro Blofeld from You Only Live Twice.

What we need is a list of names that is very long, something that there is a very large number of, and the thing we went with was cities of the world.

So what does this code do?

It makes a lot of stickers. But I should explain how.

It starts with the basic (free) Simple maps World Cities Database, which has “About 43 thousand” rows.

If we make stickers for the top 1000 most populous cities, then we get a pretty heavy bias towards Chinese cities.

That’s not in itself a problem, but it means that it’ll be a while before there’s any significant diversity of representation. The current method takes the most populous city from each country in turn. I.e. pick one from Afghanistan, Albania, Algeria, Andorra, Angola, Antigua And Barbuda, Argentina, Armenia, Aruba, then Australia, and so on. When a country runs out (for example, Monaco only has one city) it stops delivering.

The next criteria is uniqueness. Turns out that some people (mainly the British and Spanish) were very unimaginative in naming new cities (or renaming old ones). E.g. in this dataset:

⬇City Name: Shows up n times↙

  • Washington: 17
  • Springfield: 17
  • Franklin: 16
  • Santa Cruz: 14
  • San Jose: 14
  • Richmond: 14
  • Clinton: 14

So, in the spirit of being lazy, it’s first in, best dressed. Once a city name is in the main list, it’s the only one that gets to stay.

The name needs to fit on the sticker too. Naively, these names are too long, based on the number of letters:

Width in characters is only loosely related to width in picas (or any other length measure) if you’re not using a fixed width font.

i is a lot narrower than M in a variable width font. I've heuristically calculated the width of the words using this function (thanks speedplane).

There are a couple of other exclusion criteria: a ban-list for countries and a list of banned characters. (InDesign falls over on certain letters: i.e. āĀōŌī anything with a macron 😓 cries in Unicode)

Then the last exclusion criteria is that I don’t want cities that are behind the text. This one is a bit more involved because I need to know where the text is before I can tell.

In this example 👆 we’re excluding any city that is inside either of the red boxes. So Vancouver is going to be fine, because it’s well clear of the text. Sadly for Chile and Argentina, they’re going to get a raw deal. I would have preferred a Pacific centric projection, but I’m too much of a GeoPandas noob to do that. Short city names, and country names give the most possibility of not getting a clash.

In this version, I turned the text off so that I can control it slightly more precisely in InDesign. InDesign was a total pain, and in future I would stay 100% in python.

Features

  • You can either use a png marker or a MatPlotLib marker.
  • You can choose to add text or not
  • You can exclude places on a few different criteria
  • If a country is on an exclusion list
  • If the text includes certain characters
  • If the city is behind the text that labels it

I’ve tested it up to 7000 labels, it seems pretty quick.

You might still need to do a merge in something like InDesign to make sheets ready to print.

--

--