Skip to main content

Italy Open Data: Quality of Life in 20 Regional Capitals

The 20-capitals index measures museums per 100,000 residents, not quality of life. Recompute it on the ODbL CSV and see how fragile it is.

What do you think about this article?

Italy Open Data: Quality of Life in 20 Regional Capitals
Open DataPhoto:Lukas BlazekPexels

At a Glance

The 20-capitals index measures museums per 100,000 residents, not quality of life. Recompute it on the ODbL CSV and see how fragile it is.

What the index of the 20 regional capitals really measures

The dataset Quality of Life - Italian Regional Capitals 2026 Q2 has twenty rows, one per regional capital, and an index from 0 to 100 that ranks the cities from Firenze (100) down to Perugia (5.13). The name promises quality of life, but the index measures just one thing: how many museums and galleries, per 100,000 inhabitants, appear in the open data within 10 km of the centre, scaled to the highest value in the group. Theatres, libraries and restaurants are in the file as counts, but they do not enter the calculation. Reading the ranking as "the liveliest cities in Italy" is the mistake this article spares you, by showing you the numbers on the real file.

The file is published under the ODbL 1.0 licence (not CC-BY: the LICENSE file in the folder and the DCAT metadata both say so), has 16 columns and can be downloaded as CSV, JSON and GeoJSON. With three Python scripts, run on that file, you will see how the index is recomputed, how fragile it is, and why for 17 cities out of 20 the word "diversity" that appears in one column describes nothing real.

Where the numbers come from and under which licence you can reuse them

The file is built from three open sources. The counts of places come from OpenStreetMap, queried in April 2026; the identifiers and part of the places come from Wikidata; the denominator, the resident population of each municipality, comes from ISTAT (the Italian national statistics institute), year 2024. Each source carries a different licence, and the combination decides what you can do with the file.

  • OpenStreetMap: ODbL 1.0 licence, with an obligation to attribute and to share alike for derived databases.
  • Wikidata: the structured data is CC0, with no attribution obligation.
  • ISTAT: the site's content is CC BY 4.0, with an obligation to cite the source.

The constraint that matters is the OpenStreetMap one: a database built from its data can only be redistributed under the same licence. That is why the dataset is ODbL and not CC-BY, as the comment in the spec that generates it states. In practice you can use it in a commercial product as well, provided you credit "© OpenStreetMap contributors" and keep ODbL on whatever derives from it as a database. A chart you publish in a newspaper is a produced work, for which the licence only asks you to name the source.

How the museums are counted: the 10 km circle and the municipal denominator

The script that produces the file counts places with the PostGIS function ST_DWithin on geographic coordinates, with a radius of 10,000 metres around one point per city. It is not a bounding box and there is no azimuthal projection: it is a circle, with area π × 10², about 314 km², the same for every city. There are four categories: museums and galleries together, libraries, theatres, restaurants.

Here is the first thing to know. The numerator (the museums in the circle) and the denominator (the inhabitants of the municipality) describe different territories. The 314 km² circle may include neighbouring municipalities, but it may also cover only part of a very large municipality, while the population is that of the whole municipality. The ratio "museums per 100,000 inhabitants" is therefore an approximation: the smaller the city and the more it is surrounded by other municipalities, the more the circle fishes outside its administrative boundaries. The file has no column that tells you by how much, so you cannot correct the effect downstream.

The second point concerns duplicates. The script counts the rows of the places table (COUNT(p.poi_id)) and contains no step that deduplicates by Wikidata identifier. In the sister dataset on museums, which publishes the raw rows, I measured 33 Wikidata identifiers appearing in two rows (one from OpenStreetMap, one from Wikidata): the same museum counted twice. In the regional capitals dataset you cannot check how often this happens, because the file only holds totals per city.

Recompute the index in a few lines

The quickest way to stop trusting the label and trust the file is to redo the calculation. The script below reads the CSV of v1.0.0 with the csv module of the standard library, computes museums per 100,000 inhabitants, divides by the maximum and compares the result with the cultural_density_index column already published. Opening the file with newline="" is what the Python documentation prescribes for the csv module, so that the module itself handles line breaks even inside fields. The maximum gap it prints tells you whether you have understood the formula: if it were different from zero beyond the rounding to two decimals, the formula would be a different one.

import csv

with open("data.csv", encoding="utf-8", newline="") as f:
    rows = list(csv.DictReader(f))

per100k = {r["city"]: int(r["museum_count"]) / int(r["population"]) * 100_000 for r in rows}
maximum = max(per100k.values())
index = {c: v / maximum * 100 for c, v in per100k.items()}

gap = max(abs(index[r["city"]] - float(r["cultural_density_index"])) for r in rows)
print("rows:", len(rows))
print("max gap between recomputed and published index:", round(gap, 3))

for pos, (city, value) in enumerate(sorted(index.items(), key=lambda kv: -kv[1])[:5], 1):
    print(pos, city, round(per100k[city], 2), "museums/100k ->", round(value, 2))

# Output:
# rows: 20
# max gap between recomputed and published index: 0.004
# 1 Firenze 23.97 museums/100k -> 100.0
# 2 Aosta 23.72 museums/100k -> 98.95
# 3 Bologna 18.59 museums/100k -> 77.57
# 4 Milano 10.21 museums/100k -> 42.59
# 5 Cagliari 9.41 museums/100k -> 39.26

The output tells you two things. The gap of 0.004 is only the rounding to two decimals of the published columns, so the formula is exactly museums / inhabitants × 100,000, divided by the group maximum and multiplied by 100. And Firenze's first place is by construction: it is the city that defines 100, so every other city is expressed as a fraction of Firenze. Aosta, with only eight museums, sits at 98.95 because it has 33,732 inhabitants, unlike Firenze, which has 367,150: the ratio per 100,000 inhabitants is practically the same (23.72 against 23.97).

The full ranking, with the number you do not expect

The table below is generated from the data.csv file of v1.0.0, untouched. Look at the "Other POIs" column: it is the total of places minus museums, that is, libraries, theatres and restaurants put together.

The 20 regional capitals in the data.csv file of v1.0.0, sorted by cultural_density_index
#CityPopulation 2024MuseumsMuseums per 100kOther POIsIndex
1Firenze367,1508823.970100.00
2Aosta33,732823.72098.95
3Bologna392,6307318.5981877.57
4Milano1,371,49814010.213,16942.59
5Cagliari148,769149.41039.26
6Roma2,748,1092167.862,91532.79
7Trieste197,08184.06016.94
8Ancona100,49743.98016.61
9Venezia254,661103.93016.38
10Trento119,19443.36014.00
11Napoli908,240303.30013.78
12Genova563,947152.66011.10
13Torino839,809212.50010.43
14Catanzaro85,93022.3309.71
15Campobasso48,50212.0608.60
16Palermo635,439121.8907.88
17Bari313,75151.5906.65
18Potenza63,31211.5806.59
19L'Aquila69,37011.4406.01
20Perugia162,68321.2305.13

Seventeen cities have zero in the "Other POIs" column. It is not plausible that Torino, Napoli or Palermo have no library, no theatre and no restaurant: it means that for those cities the file does not contain those categories. Only Milano, Roma and Bologna have them. The most likely cause lies in the origin of the data (the extraction of those categories does not cover the other cities), but the file does not say so. The result is a two-speed table in which comparing Bologna (891 places) with Palermo (12) says nothing about the two cities.

How fragile the ranking is: one museum and the choice of group

An index normalised on the maximum has an awkward property: changing the maximum is enough to change every number. The second script runs two tests on the real file. In the first it recomputes the index within a group of seven cities, the most populous in the file, as a comparison between big capitals would do. In the second it removes a single museum from Firenze and looks at what happens to Aosta. The inhabitants do not change and no city loses its cultural offer: only the reference changes.

import csv

with open("data.csv", encoding="utf-8", newline="") as f:
    rows = list(csv.DictReader(f))
museums = {r["city"]: int(r["museum_count"]) for r in rows}
residents = {r["city"]: int(r["population"]) for r in rows}


def ranking(cities):
    d = {c: museums[c] / residents[c] * 100_000 for c in cities}
    top = max(d.values())
    order = sorted(d, key=lambda c: -d[c])
    return order, {c: round(d[c] / top * 100, 2) for c in cities}


all_cities, index_20 = ranking(list(museums))

# The seven most populous cities in the file: same shape as a "big capitals" pool.
seven = sorted(residents, key=lambda c: -residents[c])[:7]
order_7, index_7 = ranking(seven)
print("pool of 7:", ", ".join(seven))
for c in order_7:
    print(f"{c:8} index in the pool of 20: {index_20[c]:6}  in the pool of 7: {index_7[c]:6}")

# What happens if OSM loses (or gains) a single museum in Firenze?
museums["Firenze"] -= 1
_, index_minus1 = ranking(list(museums))
print("Firenze with 87 museums: Aosta moves from", index_20["Aosta"], "to", index_minus1["Aosta"])
print("and takes first place:", ranking(list(museums))[0][0])

# Output:
# pool of 7: Roma, Milano, Napoli, Torino, Palermo, Genova, Bologna
# Bologna  index in the pool of 20:  77.57  in the pool of 7:  100.0
# Milano   index in the pool of 20:  42.59  in the pool of 7:   54.9
# Roma     index in the pool of 20:  32.79  in the pool of 7:  42.27
# Napoli   index in the pool of 20:  13.78  in the pool of 7:  17.77
# Genova   index in the pool of 20:   11.1  in the pool of 7:  14.31
# Torino   index in the pool of 20:  10.43  in the pool of 7:  13.45
# Palermo  index in the pool of 20:   7.88  in the pool of 7:  10.16
# Firenze with 87 museums: Aosta moves from 98.95 to 100.0
# and takes first place: Aosta

In the group of seven cities Bologna becomes the reference and goes from 77.57 to 100, Roma from 32.79 to 42.27: the order of the cities stays the same, but the values are not comparable with those of the file of twenty. The second experiment is even more instructive: with 87 museums instead of 88, Firenze drops below Aosta, which takes first place. A single place mapped (or deleted) in OpenStreetMap overturns the top of the ranking. That is why it makes little sense to quote "Firenze first, Aosta second" without saying that the difference between the two is less than one museum.

A practical rule follows for anyone using this file. Compare cities by the number of museums per 100,000 inhabitants, which has a physical meaning, and not by the index, which depends on the group; always report the absolute count next to the rate; treat any difference smaller than a couple of museums on the small cities as unreliable.

Which version to download: v1.0.0 or v1.1.0

On the site the dataset folder holds two versions. v1.0.0 is the one this whole article refers to. v1.1.0, dated 30 July 2026, carries only the word "regeneration" in its change log. The third script compares it with the first, using in-memory sqlite3: it loads the rows into a temporary table and counts how many cities have only museums and how many have zero museums. It writes no file and uses no database on disk.

import csv
import sqlite3


def load(path):
    con = sqlite3.connect(":memory:")
    con.execute("""CREATE TABLE city (city TEXT, museum_count INT, library_count INT,
                   theatre_count INT, restaurant_count INT, total_poi_count INT)""")
    with open(path, encoding="utf-8", newline="") as f:
        for r in csv.DictReader(f):
            con.execute("INSERT INTO city VALUES (?,?,?,?,?,?)",
                        (r["city"], r["museum_count"], r["library_count"],
                         r["theatre_count"], r["restaurant_count"], r["total_poi_count"]))
    return con


for version, path in (("v1.0.0", "data.csv"), ("v1.1.0", "data_v110.csv")):
    con = load(path)
    museums_only = con.execute(
        "SELECT COUNT(*) FROM city WHERE library_count + theatre_count + restaurant_count = 0").fetchone()[0]
    no_museums = con.execute("SELECT COUNT(*) FROM city WHERE museum_count = 0").fetchone()[0]
    with_all = con.execute(
        "SELECT group_concat(city, ', ') FROM city WHERE library_count + theatre_count + restaurant_count > 0"
    ).fetchone()[0]
    print(version, "- cities with museums only:", museums_only, "- cities with 0 museums:", no_museums, "- cities with more categories:", with_all)

# Output:
# v1.0.0 - cities with museums only: 17 - cities with 0 museums: 0 - cities with more categories: Bologna, Milano, Roma
# v1.1.0 - cities with museums only: 17 - cities with 0 museums: 17 - cities with more categories: Bologna, Milano, Roma

In v1.1.0 seventeen cities out of twenty have zero museums, and among the other three the numbers are lower: Bologna goes from 73 to 58 museums, Milano from 140 to 124, Roma from 216 to 166. With these values the index puts Bologna at 100 and Firenze at 0. I cannot say whether the cause is an incomplete extraction or something else: the file does not say. What I do say is that, as published, the v1.1.0 file is not suited to comparing cities. Use v1.0.0 for your analyses.

There is a consequence for citation as well. The "concept" DOI 10.5281/zenodo.20804749 always resolves to the latest version, today v1.1.0 (the Zenodo pages, consulted on 2026-11-13, confirm it). Anyone who wants to cite the data this article is based on must use the version DOI 10.5281/zenodo.20804750, which points to v1.0.0.

Limits to declare when you publish a result

Before quoting a ranking derived from this file, check these points. They are not routine precautions: they are the points where the file, once measured, departs from what the title suggests.

  • Uneven coverage: libraries, theatres and restaurants are mapped for three cities out of twenty.
  • Non-matching territory: a 10 km circle for the places, municipal boundaries for the inhabitants.
  • Possible duplicates between the OpenStreetMap and Wikidata rows, with no column to flag them.
  • Residents only: no correction for tourists, out-of-town students or commuters.
  • No weighting and no quality: a neighbourhood museum counts the same as the Galleria degli Uffizi.

The three items that change the result most are the first two and the fourth. Coverage makes the comparison with Milano, Roma and Bologna always lopsided; the territory makes the rates of small cities unstable; residents penalise tourist destinations. Serious work picks one of these corrections and declares it, or sticks to museums, where coverage is uniform.

Download, cite, reuse

The v1.0.0 files are hosted under the path /open-data/quality-of-life-italian-capitals/v1.0.0/ of the site. The CSV weighs 4,309 bytes, uses the CRLF line separator required by RFC 4180 (I checked by counting the line breaks) and has 21 rows, header included.

For readers less familiar with the formats: the CSV is enough for a spreadsheet or for the scripts in this article, while the GeoJSON is only needed if you want to put the cities on a map. For the citation, use the form that the citation.json file in the folder proposes for v1.0.0: Calò, F. (2026), Quality of Life - Italian Regional Capitals 2026 Q2 (v1.0.0), Zenodo. On the dataset page, /en/open-data/quality-of-life-italian-capitals, you will find the catalogue and the citation blocks.

Where the series continues

The same verification method works on the other datasets in the series. In the article on the 1,634 Italian museums you work on the raw rows and find the duplicates I mentioned. The comparison among European capitals, which should extend this index, is in Quality of Life in the 7 EU capitals, where you will see why that dataset is not yet published. And to understand why a licence such as ODbL changes what you can build, the register of geographical indications in Food PDO PGI TSG compares a case with different licences.

Frequently asked questions

Can the regional capitals dataset be used in a commercial product?

Yes, the ODbL 1.0 licence allows commercial use. You must credit "© OpenStreetMap contributors" and the dataset, and if you redistribute a derived database you must keep the same licence (share-alike). A chart or an article built on the data is a produced work and only requires naming the source.

Why does Firenze have 100 and Aosta 98.95 if Aosta has only 8 museums?

Because the index measures museums per 100,000 inhabitants, not absolute museums: Aosta has 23.72 museums per 100,000 inhabitants, Firenze 23.97. With a single museum fewer in Firenze, first place goes to Aosta, as the second script shows.

Does the poi_diversity_index column measure the variety of cultural places?

No. It is the city's total of places divided by the highest total in the group, times one hundred: in v1.0.0 it is 100 for Milano and 94.62 for Roma. For the seventeen cities that have only museums it is proportional to the number of museums, so it is a volume index, not a variety index.

Which version should I use to compare cities?

v1.0.0. v1.1.0, published on 30 July 2026, has zero museums in 17 cities out of 20 and does not allow a comparison. When you cite the dataset, use the version DOI 10.5281/zenodo.20804750 and not the concept one, which always points to the latest version.

What you can do now

You know that the index of the 20 regional capitals is a density of museums normalised on the maximum, and you can recompute it in a few lines of Python. You know that its top position can change by one museum, that the value depends on the group of cities chosen and that coverage of the other categories exists for three cities out of twenty. Finally, you know which version to download, how to cite it with the right DOI and which limits to declare next to a result.

Sources

The three listings were run with Python 3 from the standard library (modules csv and sqlite3) on the data.csv of v1.0.0 and, for the comparison, on that of v1.1.0, both taken from the frontend/public/open-data/quality-of-life-italian-capitals/ folder of the repository. Each output shown is identical across two consecutive runs. The code of the spec that generates the file is ml-service/app/publishing/dataset_specs/quality_of_life_italian_capitals.py.

Try These Tools

Free developer tools related to this topic.

Commenti

Caricamento commenti...

Sign in to comment

New articles and tools on Telegram too

The Telegram channel flags the site's new articles and tools.

Did you like this article?

Explore other content on the blog or discover my projects