Cheese with Holes (Emmental) - Developing
Cheese with Holes (Emmental) - Developing
Useful note with basic structure, but still has holes to fill.
Click the cheese icon to learn more

How a Heatmap Can Mislead You

Author: guiferviz Created: Last Modified:

Imagine you want to open a small coffee shop in your city. You do not want to choose the location just by vibes, so you collect a bit of data: delivery orders, searches for “coffee near me”, breakfast purchases, maybe a few other signals that smell like morning caffeine.

The first thing you get is not a beautiful map. It is just a cloud of points. Some places look busier than others, sure, but it is still hard to turn that into an actual decision. If someone asks “where should we open?”, pointing at a messy scatter plot does not feel very convincing.

From Points To Regions

This is where heatmaps and choropleths become tempting. They take the cloud and turn it into something that looks much easier to read.

The recipe is simple:

  1. Lay a grid on top of the city.
  2. Count how many events fall inside each cell.
  3. Paint each cell with a color scale.

Now we are not staring at isolated orders anymore. We have regions. Hot spots. Cells that look important. The map starts to say something.

This is not a bad trick. Aggregation is useful. Most of the time, it is the only reason the data becomes readable at all.

But there is a catch: the result now depends on something that was not in the raw data.

It depends on the grid.

The Grid Is Part of the Model

When we look at the aggregated version, it is very easy to treat the cells as if they were natural neighborhoods. But they are not. We placed those borders there.

That means the map is not just showing demand. It is showing demand after we forced it through one particular way of cutting space.

Move the grid a little and some points cross a boundary. One cell loses a few orders. Another one absorbs a small cluster. Suddenly the “best” area is not quite the same.

Nothing about the customers changed. Nothing about the orders changed. Only the boundary moved.

That is the core of the Modifiable Areal Unit Problem, usually shortened to MAUP:

The pattern you see can depend on how you grouped the same underlying data.

That sounds a bit academic, but the practical version is very simple: if the story changes when the boxes move, the story was partly about the boxes.

Three Small Choices With Large Consequences

There are a few choices hiding inside every map like this:

  • Origin: where the grid starts.
  • Scale: how large each cell is.
  • Shape and orientation: squares, triangles, hexagons, rotated grids, and administrative shapes do not pool points in the same way.

Those choices can look cosmetic. They are not. They decide which points become neighbors and which ones are split apart.

Try it below. Drag the grid around. Make the cells larger or smaller. Rotate the overlay. Swap squares for triangles, hexagons, or postcode-like regions.

The points stay the same. The summary does not.

Postal codes deserve a special mention because they feel official. They have names, rules, and sometimes even a bit of cultural identity. But they were not designed to discover demand patterns for your coffee shop. They were designed for administration and delivery.

The same thing can happen with neighborhoods, states, regions, or countries. A boundary can be useful and still be a bad match for the behavior we are trying to measure.

So a heatmap is not raw truth. It is a modeling output. A useful one, often, but still an output of choices.

Not Just a Spatial Problem

Once you see this in maps, it becomes easier to spot elsewhere.

The deeper problem is not “maps are weird”. The deeper problem is that whenever we group data, the boundary starts participating in the answer.

Spatial cells do this. Administrative regions do this. Product categories, age bands, school districts, sales territories, and time buckets can do it too.

A Year Is Also A Boundary

Take the S&P 500 at monthly resolution. The raw data is just a long sequence of monthly values. But the moment we summarize it as “yearly performance”, we quietly choose a boundary.

When does the year begin?

Calendar years begin in January. That is useful, and everyone understands it. But it is still a convention. A fiscal year might begin in April. A reporting cycle might begin in July. The monthly data is identical, but the twelve-month containers move.

The visual below keeps the monthly history fixed and only changes where the row starts. Each row is still twelve months. The only thing moving is the boundary.

And yet the story changes. Some rows become more positive. Others lose their shine. A bad month can move from one “year” to another, and suddenly the summary looks different.

This is the temporal version of the same problem. We start treating the aggregated year as if it were a natural object, when really it is a frame we put around the sequence.

Experiment

Try changing the start month of the year and observe how the yearly summaries change. A few examples stand out:

  • 2020 has a return of around +16% when the year starts in January. But if the year starts in April, after the sharp pandemic drawdown, it shows a return of around +53%.
  • 2024 looks very strong with a calendar-year return of around +23%. But if the year starts in April, the 2024/25 period looks much more modest, with a return of around +6%.
  • Even 2022, which looks very weak as a calendar year at around -19%, can look almost flat, close to 0%, if the year starts in May.

Arbitrary Does Not Mean Useless

At this point it is tempting to say: “Fine, all boundaries are fake, throw them away.” But that would go too far.

A calendar year is a convention, but it is not meaningless. People plan around it. Companies report around it. Holidays, budgets, taxes, and habits all make December and January feel different in practice.

The same is true for geography. Postal codes, census tracts, and neighborhoods may reflect real differences in how places are built, governed, or lived in. Sometimes a boundary really does separate two different environments.

The point is not that boundaries are always wrong. The point is that they are not neutral.

Aggregation requires a choice. Different reasonable choices can produce different summaries from the same data. A pattern can look strong under one grouping, weak under another, and sometimes disappear entirely.

Can Smoothing Help?

One common response is to smooth the map. This can be a good idea. If nearby cells are supposed to describe the same continuous process, averaging with the neighbors can reduce noise and make the broader structure easier to see.

One popular option is a Gaussian filter. Instead of using only the count in a cell, we replace it with a weighted average of nearby cells. Close neighbors get more weight. Farther neighbors get less.

That usually makes the surface cleaner. But it does not make the MAUP disappear. The smoothing happens after we already chose the grid. It can soften the edges, but it still inherits the partition we started with.

The last visual lets you edit a small Python implementation of a Gaussian filter. The map on the right updates from the code on the left. Move the grid around and notice that the smoothed surface still changes, because the counts it smooths came from a particular aggregation.

What To Do in Practice

The lesson is not “never aggregate”. That would be silly. Aggregation is how we make many datasets understandable.

The better rule is:

  1. Treat aggregation choices as assumptions.
  2. Check whether your conclusions survive shifts in origin, scale, cell shape, year start, or administrative boundary.
  3. Report patterns that remain stable across reasonable groupings.

If a recommendation appears only for one lucky grid, it is probably not strong enough to trust. If it survives several reasonable ways of grouping the same data, then we can start taking it more seriously.

That is what makes MAUP important. It reminds us that a summary is not only a lens over the data. Sometimes the lens bends the image.