FlowsBook a callSign inCreate free accountSign up
Population and demographics

How to convert population hexagons to postcodes and sales areas

Population comes in small hexagons, but reports run on postcodes, districts and sales areas. Two ways to add the hexagons up into the areas your team uses.

Part of the guide Location intelligence automation

By the xMap team · · 6 min read

To convert population hexagons to postcodes, districts or sales areas, you add up the residents of every hexagon that falls inside each area. In xMap Flows there are two ways to do it: paste or draw the boundaries in an Area of interest and let Demographics return one total per shape, or take every hexagon and give each one to the nearest of your own points, then add them up by that point. The first suits fixed boundaries such as postal codes; the second suits sales areas built around stores or reps.

This is for analysts and planners whose maps, budgets and targets are written by postcode or territory, not by grid cell. It explains why the hexagons exist, both methods step by step, what happens at the edges, and how to keep the totals fresh without doing it again by hand.

Why population comes in hexagons at all

xMap's population grid splits the land into hexagons of about 0.1 km² each (the H3 grid at resolution 9). Every hexagon carries its residents, men and women, and nine age groups. The grid is the same size everywhere, which is why it is useful: a hexagon in a dense centre and one on the edge of town can be compared directly, and any shape you care about can be built from them like tiles.

Postcodes and districts are the opposite. They are drawn for letters, votes or tax, they vary wildly in size, and they change from time to time. Nobody wants to read a plan in hexagon codes, though, so the job is always the same: tiles in, named areas out. The H3 hexagons page explains the grid itself in more detail.

Method one: boundaries in an Area of interest

Use this when the areas already exist as shapes: postal codes, municipal districts, a franchise map someone made in a GIS.

  1. Export the boundaries you need as GeoJSON from your GIS or mapping tool (Polygon, MultiPolygon, Feature or FeatureCollection all work).
  2. Add an Area of interest, choose Draw on a map, and paste the GeoJSON. You can also draw a sales area by hand next to the pasted ones.
  3. Add Demographics after it with Where set to Area of interest and Give back set to Totals for each area.
  4. Run it once and open the result: one row per shape with its population, men and women, the age groups, its area in km² and people per km².
  5. Send the rows to a Google Sheets tab or an email, or keep them on a map.

The shapes come back as Drawn area 1, Drawn area 2 and so on, in the order they were pasted. Keep the order in your own list (postcode in one column, the drawn area number in the next) so you can put the right code against each total. Doing ten or twenty postcodes per flow keeps that list short and easy to check.

Each shape is added up from the hexagons inside it, so the totals follow your boundary rather than a circle drawn around its middle. A big shape is searched in parts of about 170 km², up to roughly 4,200 km² per area; a whole region larger than that should be split first.

Method two: every hexagon, given to its nearest point

Sales areas are often not shapes at all. They are "everything closest to this store" or "the streets this rep covers from home". For those, skip the boundaries and let distance decide.

  1. Set an Area of interest around the whole city or region you plan, as cities or a drawn outline.
  2. Add Demographics with Give back set to Every hexagon. Each hexagon arrives as its own item with its H3 index, its centre and its counts (up to 5,000 hexagons a run).
  3. Add Find nearest with a CSV or a My data table of your stores, depots or reps' bases. Give the fields a short prefix such as store, so each hexagon gains store_name and store_km.
  4. Add the Data analyst and ask in plain words: "add up population, children_0_19 and seniors_60_plus by store_name, largest first".
  5. Show the hexagons on a map coloured by store, so everyone sees where each sales area ends.

The result is a table with one row per store: how many residents are closer to it than to any other of your sites, and how they split by age. It is a fair first draft of territories, and the same table tells you where two stores are fighting over the same streets.

A worked example in Lyon

Say a home-care company in Lyon has its targets written by postal code, and four agencies that each serve the streets around them. These numbers are made up to show the steps. The planner pastes the boundaries of eight postal codes into an Area of interest and runs Demographics with totals: eight rows come back, and the column for people aged 60 and over shows that two of the eight codes hold far more older residents than the agency covering them was staffed for.

In a second flow the planner takes every hexagon across the city, gives each to the nearest of the four agencies, and asks the Data analyst to add up residents aged 60 and over by agency. One agency turns out to have the largest older population within its reach while holding the smallest team. Both answers come from the same grid; the first speaks the language of the targets, the second the language of the people doing the visits.

What happens at the edges

  • Hexagons are counted whole. A hexagon is about 0.1 km², so a boundary cuts through some of them. Large areas barely notice; a postcode of a few blocks is only as precise as the handful of hexagons it holds.
  • Small numbers wobble. A total of a few hundred residents in a tiny area should be read as a range, not a figure to the person.
  • Nearest is straight-line distance. Find nearest measures as the crow flies. Across a river with few bridges, the nearest store on paper may be the longest trip. For reach along the roads, a Travel area per store gives drive or walk areas to total instead.
  • Residents are not visitors. The grid counts people who live there. A business district may hold few residents and many workers by day.

Keeping the totals current with an AI employee

Done by hand, this is the sort of work that is done once and then goes stale. As a flow it can sit on a monthly schedule: the boundaries stay in the Area of interest, the stores stay in My data, and when you add a branch the territories redraw themselves on the next run. A Make a report block can turn the table into a PDF with a map for the board, and an email lands with the totals for each area.

If the same split is needed in several cities, build it once and make linked copies with a different Area of interest in each. Planning work like this sits within location intelligence automation, where the point is that the numbers arrive without anyone redoing the arithmetic.

Questions

Can xMap Flows look up a postcode by its code?

No. It has no built-in list of postcode boundaries. You paste the boundaries you have as GeoJSON into an Area of interest, and Demographics totals the residents inside each one.

Why not just use a circle around the postcode centre?

Postcodes are rarely round. A circle wide enough to cover a long, thin postcode also takes in its neighbours, so the totals run high. Adding up the hexagons inside the real boundary avoids that.

How many hexagons can one run return?

Up to 5,000, which is about 500 km². A map shows up to 2,000 of them at once. Split a bigger region into parts or into linked copies.

Does it work for the United Kingdom or the United States?

Not yet. The population grid covers about 100 countries but not those two, so totals there come back as 0.

Can I total the hexagons by sales rep instead of by store?

Yes. Put your reps' home bases or their territory centres in the CSV for Find nearest, then ask the Data analyst to add up by rep.

Templates that do this

Read next

More on population and demographics · Every article · Templates

Put it to work

An AI employee in xMap Flows does this on live data, on its own timetable. Start from a template or describe it in plain words.