Skip to main content

Application: mapit

GOV.UK fork of Mapit, a web service to map postcodes to administrative boundaries

AWS, on the mapit machine class
Rake tasks
Integration, Staging or ⚠️ Production ⚠️

Relevant manual pages

Imported documents


This is a fork of the MapIt repo. MapIt is a Python/Django application (backed by PostgreSQL), that provides RESTful API for looking up postcodes, council boundaries, etc.

Avoid adding features, changing behaviours, or touching the code of MapIt itself. The only differences against the original repo should only be to help integrate it into the GOV.UK stack. So far this includes:

If we need to change the code itself, we should communicate with mysociety to try and push the work back upstream so everyone benefits.


  • Area: a set of points that define an area that represents a geopolitical boundary of some sort. A country, a parliamentary constituency, a national park, a civil parish, etc.
  • Postcode: an identifier for a small geographical area usually derived from postal data. Postcodes don’t have boundaries, instead they have a lat/lng point which is the centroid of their area. The Areas for that Postcode are looked up by doing a geo search for those that contain the point.
  • Generation: because areas change over time we add Areas to generations. If an area is in one generation but not another it is likely because legislation was enacted between those generations that meant it ceased to exist (often it is replaced by another similar but not exactly the same Area). Unless specified in the request mapit only searches in the current generation.
  • Type: to identify what an area is it has a type. For example European parliamentary constituencies are type ‘EUR’ compared to Westminister parliamentary constituencies of type ‘WMC’.
  • CodeType: Areas have codes to allow them to be identified, issued by the ONS. Prior to 2011 these were SNAC codes (stored as type ‘ons’) (see:–codes-and-look-ups/standard-names-and-codes/index.html), since 2011 these are GSS codes (stored as type ‘gss’) (see:
  • ONSPD: The Office for National Statistics Postcode Database - one of the open data sources we use to import data. We get UK postcodes from this.
  • Boundary Line: The Ordnance Survey boundary line data - one of the open data sources we use to import data. We get GB Areas from this.
  • OSNI: The Ordnance Survey of Northern Ireland - one of the providers of the open data sources we use to import data. We get NI Areas from them.
  • ONS: Office for National Statistics
  • GSS: Government Statistical Service, new ONS codes - GSS codes start with a letter, and are 9 characters long e.g. S14000051
  • SNAC: old ONS codes - ONS codes consist of a number and/or character combination that could be 2, 4, 6, 8, or 10 characters long, and depending on the length, may only be numbers
  • SRID: spatial reference identifier

Technical documentation

You can use the GOV.UK Docker environment to run the application and its tests with all the necessary dependencies. Follow the usage instructions to get started.

Use GOV.UK Docker to run any commands that follow.

Running the application

To run management commands in other (non-development) environments, you’ll need the GOVUK_ENV environment variable set.

Running the test suite

./ test mapit mapit_gb

Further documentation


GNU Affero GPL