4 min read

Italian-provinces-themed juice caps - an exploration

Following this post, you will find out how to:

  • match province identifiers to a map (easy!)
  • make a palette based on the prevalent colour of a set of images (easier than I thought)
  • place a set of png images on a ggplot canvas (the trick part is adapting size to the number of caps)
  • place png images on an interactive leaflet map (always fancy)
  • estimate how many bottles of juice you’re supposed to drink in order to finish your collection (serious questions)
  • build a wasm-based, server-less shiny app with all of the above (so much wisdom can’t be accessible only to those who code)

In May 2024, Italian brand “Yoga” has started to place on caps of its small glass bottles of fruit juice a set of decorations themed after Italian cities (“Tutte le mie città”). The full set includes 107 different caps, one for each Italian province.

Picture from Yoga’s website
Picture from Yoga’s website

The design is quite nice, and for someone with kids, a good occasion to get to know better Italy’s geography, including the location of somewhat smaller - or just distant - cities. How is the geographic coverage of our collection going? At the same time, it’s also an obvious occasion to talk about statistics: how many fruit juice bottles will we have to drink in order to have a full set, considering that bottles are sold in cartons of 6, each with random caps?

As you see, big questions.

So, if you will indulge me…

Which parts of Italy does our collection cover?

Frmo the very beginning, things bode well. Each cap has the name of the pronvicial capital(s) and a number, from 1 to 107. The numbering does not correspond to the one used by the Italian statistical office, but places cities in alphabetical order, so it’s an easy fix.

We can take the official dataset with administrative boundaries from ISTAT’s website, distributed with a CC-BY license, and we’re immediately ready to match caps to administrative boundaries.

Let’s take a random sample of six caps, and place them on a map, adding the respective label:

With labels… nice and easy! If we had all provinces we’d probably need to include only the province id and not the name, or just fill the area without code, but there’s not much we can do about it

There is however, something that is deeply unsatisfying: the fill colour of the provinces.

And the good thing is, there is a satisfying answer to this question: each of the caps has one of small sets of background colours… overall, a nice palette. Shouldn’t all provinces take the colour from the respective cap? Of course they should!

Getting the background colour of each cap

Manually retrieving the backgroun colour of 107 caps would be more than these typing-loving hands would be willing to accept, so, an alternative solution must be found.

And indeed, we are in good luck: the website of the initiative hosts not one, but two full sets of of images of caps! Even better, they are hosted with predictable names:

  • higher resolution 3d render of caps (see e.g. cap 1, and adjust the filename to see the following)
  • lower resolution 2d render of caps (see e.g. cap 1, and adjust the filename to see the following)

Let’s retrieve them all, as we’ll need them for reference.

And let’s have a look at the above-selected random set of caps, first in the basic version:

then in the high resolution one:

These are really very nicely designed!

Anyway… here’s what we have achieved so far. Based on a set of cap identifiers, we can:

  • create a map and show the provinces corresponding to the selected caps
  • preview the caps themselves as a picture

The next task of the masterplan is to identify the background colour of each cap, in order to use it when showing selected provinces on the map.

[TO DO: post in progress - I’ve actually done most of the coding for everything announced on top of the post, I just need the time to write up the accompanying text]


P.S. if you’re reading this from Italy, and you have some active memories from the last century… you may remember how another established fruit juice company used to run a somewhat similar campaign: caps with country flags. Let me unlock this memory for you, with this picture from ebay.

Picture from Ebay/galactic.poacher
Picture from Ebay/galactic.poacher