MapIt is a service that maps geographical points to administrative areas. This edition is based on source data from the totally amazing OpenStreetMap project, so add your boundaries there if they’re missing. If you’re in the UK our MapIt UK with open Ordnance Survey data will probably be more useful.

MapIt is useful for anyone who has the co-ordinates of a point on Earth, and who needs to find out what country, region, city, constituency, or state it lies within. It’s also great for looking up the shapes of all those boundaries.

Charitable, low volume use of this service is free – read more.
You can download the source on Github.
Need a licence? Read more.

MapIt API Documentation

The documentation below is for developers who want to use MapIt as a web service, describing its REST API. If that’s all Greek to you, please see our page for non-developers.

lookup by point

URL:
  • /point/[SRID]/[x],[y]
  • /point/[SRID]/[x],[y]/box
Parameters:

SRID is a unique number referring to a particular co-ordinate system; the one you probably are interested in is 4326 for WGS84 normal lon/lat.

x and y are the co-ordinates of the point in the co-ordinate system; note that x,y means longitude,latitude.

Optional query parameters:
  • type, to restrict results to a particular area type or types (multiple types separated by commas);
  • generation, to return results for a previous generation.
  • min_generation, to return results since that generation.
  • country, to restrict results to areas with particular country codes (multiple country codes separated by commas).
Returns:

A hash of the areas that the point is contained within. If the /box version is used, only the area bounding boxes are considered.

Example:
Example of areas containing (47.366667,8.55).

lookup by area

URL:
  • /area/[area ID]
  • /code/osm_rel/[OSM relation ID]
  • /code/osm_way/[OSM way ID]
  • /area/[area ID]/geometry
  • /area/[area ID].[kml or geojson or wkt]
  • /area/[SRID]/[area ID].[kml or json or wkt]
Optional query parameters:
simplify_tolerance, a floating point parameter to simplify the polygons returned.
Returns:
Information on a particular area, including name, type, parent, and any associated codes (see below for details). The code lookups redirect to the area URI. geometry returns centroid, extent and area of the area.
Examples:

lookup multiple areas

URL:
  • /areas/[area IDs]
  • /areas/[area IDs]/geometry
  • /areas/[area IDs].[kml|geojson]
  • /areas/[type(s)]
  • /areas/[name prefix]
Parameters:
Separate multiple parameters with commas. Name prefix means it will return any area that starts with the string given. The current area types are: O01 to O12.
Optional query parameters:
  • generation, to return areas in that generation (type and name lookups only).
  • min_generation, to return areas since that generation (type and name lookups only).
  • type, to restrict results to a type or types (multiple separated by commas; name lookup only).
  • country, to restrict results to areas with particular country codes (multiple separated by commas; type and name lookups only).
Returns:

Information on multiple areas that match the parameters provided, as a dictionary indexed by area ID. The geometry argument lets you fetch multiple single area geometry results at once.

Examples:

lookup by code

URL:
  • /code/[code type]/[code]
Parameters:
code type and a code should uniquely identify an area. (MapIt uses code types and codes to associate external identifiers with areas.) The current code types are: osm_rel (OSM relation ID) and osm_way (OSM way ID)
Returns:

This returns an HTTP 302 Found redirect to the corresponding /area/[area ID] page. Any format extension (.html or .json) will be preserved in the URL that's redirected to.

Examples:

Generations

URL:
/generations
Returns:
A list of all generations in this installation of MapIt.
Example
List of generations

General information

Format

All calls return JSON, you can generally get an HTML representation by sticking .html on the end.

Whenever an area is returned from MapIt, it is as a dictionary with the following keys: id, name, country, type, parent_area, generation_low, generation_high, codes.

Historical areas
By default, calls will return active areas; for some calls you may specify a previous generation to look up instead.

About MapIt

MapIt was written back in 2003 as a postcode lookup to power the original mySociety sites such as WriteToThem. Over time it gained features such as point lookup (for FixMyStreet), and when Ordnance Survey data became freely available in 2010, it was rewritten and made public for the whole UK. Versions have appeared in other countries, such as Norway, and in 2012 we released this global version based on OpenStreetMap data.

Usage & Licence

As a UK registered charity our legal status only allows this service to be used free of charge by other registered charities, or individuals working unpaid on non-profit projects. The free usage limit for non-profit users is 50,000 calls to the API per year. All other uses need to acquire a licence.

To maintain quality of service for our own websites, as well as our API users, this service is rate limited to an average of 1 call per second in a rolling 3 minute period.

If you use this service, you must attribute OpenStreetMap as per their licence. We also ask that all non-profit users attribute MapIt at the point of use on sites or apps. Attribution should use the text “Powered by MapIt”, with a link back to this page.