Flexipy
Industries · Services · Products

Work · a global geodata provider

Population statistics for any polygon a user can draw

01 The engagement

The problem

Demographic data existed as national tables and raster files. Answering "how many people live inside this shape" meant a GIS specialist, a desktop tool and a manual export, so a question that took a customer ten seconds to ask took days to answer — and could not be sold as a product.

The approach

A PostGIS service behind a versioned REST API. A user draws a boundary or uploads a shapefile, the parts are unioned into a single signature polygon, and population figures are computed against it — totals, density, growth rate, household size and age bands from 0–4 upward — then returned through the API or exported as KML. The work runs as Celery jobs with their own status rows, so the client polls rather than holds a connection open.

02 The engineering

What was technically hard

A shape a user draws is not a shape a database likes. Uploaded shapefiles arrive with 3D coordinates that have to be flattened before PostGIS will accept them, in whatever projection the source happened to use, and with parts that overlap each other. Every boundary is normalised and unioned before anything is computed against it, and each recomputation bumps a revision counter with a database-level increment, because the same target group can be edited by two people while a job for the previous version is still running.

One decision we made, and why

The service refuses a query whose area exceeds a configured limit, and says so with its own status rather than failing. An unbounded polygon over a global dataset is not slow, it is effectively infinite — and a job that never finishes looks identical to one that is still working. Naming the refusal turned a hang into an answer a customer could act on.

More work

start-project.sh

$ tell us what you're building and where it's stuck

Book a 30-min discovery call

We reply within one business day.

Let's talk about your build

Pick a time, or leave a note and we'll reply within one business day.

Stanislav Rybonka · Founder & Principal Engineer

Pick a time →
or write to us