--- layout: page title: Admin boundaries --- # Admin boundaries and FixMyStreet
When you set up FixMyStreet, you usually need to provide admin boundaries for each of the bodies you'll be sending reports to. If you're lucky, the boundaries might already be available. If not, you'll have to make them. This page explains your options.
## Why FixMyStreet needs boundaries When someone sticks a pin in the map to report a problem, FixMyStreet uses boundaries to answer the question: _who is responsible for fixing problems **here**_? This also means that boundaries can be used to determine if the pin has been put somewhere that is *not* covered by any bodies.This is the default setup of a new FixMyStreet installation (if you used e.g. the installation script or the AMI install).
Set
MAPIT_URL
to be blank, and set
MAPIT_TYPES
to the special value ZZZ
. FixMyStreet will use a fake MapIt that always
returns "Everywhere" as the only area that contains the point — for any
location.
Your conf/general.yml
file should contain this:
MAPIT_URL: ''
MAPIT_TYPES: ['ZZZ']
MAPIT_ID_WHITELIST: [ ]
You need to install your own MapIt instance, and add the area to that. The MapIt admin interface (which uses the Django framework) lets you click-and-draw a polygon over a map. Alternatively, we run a MapIt server for custom areas like this, so — especially if you are just doing this as a probationary trial — we may be able to host this for you (note though that we do rate-limit calls to MapIt). Either send us KML shape files, or if you can't do that, maybe a clear image of the map with the boundary drawn on it for us to copy.
In your conf/general.yml
, you must set
MAPIT_URL
to either your MapIt or our custom one, and set
MAPIT_TYPES
to the areas you want (the actual values will depend on what that particular
MapIt is returning). You should also set
MAPIT_ID_WHITELIST
to the ID of the single area you want.
MAPIT_URL: 'http://mapit.example.com'
MAPIT_TYPES: ['CITY']
MAPIT_ID_WHITELIST: [ 133 ]
Same as previous example: either set up your own instance of MapIt, or ask to have your boundaries added to our custom one. If you want us to host it, we'll need KML shape files or a graphic showing the boundary clearly shown so we can copy it.
Note that now there may be more than one type of area, and you'll need to explicitly
nominate every area you're interested in with
MAPIT_ID_WHITELIST
(unless you want *all* the areas this MapIt returns for the given type, in
which case you can set it to be empty).
MAPIT_URL: 'http://mapit.example.com'
MAPIT_TYPES: ['CITY', 'COUNTY']
MAPIT_ID_WHITELIST: [ 133, 145, 12, 80 ]
Start by finding the lat-long of some of the places you want to cover, and look them up on global MapIt (or maybe the UK one). If you see the "Areas covering this point" include the admin boundaries you need, you're good to go! For example, here's the page for Oslo, in Norway.
Note that our MapIt servers' data may lag a little behind OSM, so if it's not there, look on the OpenStreetMap website just in case it's been added since MapIt's last update. If so, let us know, and we'll pull it in for you.
Here's an example of the steps to follow to find the data you need to use global MapIt. This example uses Zurich as an example city.
Go to OpenStreetMap's geocoder and enter the name of the city, e.g., "Zurich, Switzerland".
Check that's found the right place (and, if you want, check the map
is how you expected). Click on the details link just
below the name of the top hit. The details page lists lots of data,
including the centre point (lat/long values that will look something
like -34.9059039,-56.1913569
).
Go to global MapIt and paste those lat/long values into the text input.
MapIt will show you all the admin boundaries
that contain that point. You're interested in
the ones that relate to bodies that serve those areas. For example,
if a district council fixes the potholes in that district.
Specifically, you need the Administrative Boundary
Levels (which will look like O04
or
O05
), which are the values for your
MAPIT_TYPES
.
Remember this data is boundary data from OpenStreetMap —
if the boundaries you need are not shown, you may have to set up your
own (described below). You can also click on any of the boundaries
listed on MapIt to see the areas they actually cover on the map.
The individual area_ids are also useful, because you put
them into the MAPIT_ID_WHITELIST
.
We run two public MapIt services: mapit.mysociety.org covers the UK (because that's where we're based, and it serves our own UK FixMySteet site), and global.mapit.mysociety.org, which covers the whole world. The data we use for global MapIt is from OpenStreetMap, so if someone has put administrative boundary data for your country into OSM, before too long global MapIt will have it too.
Please get in touch with us if you are expecting to generate a lot of requests or if you are using it commercially. We rate-limit calls to MapIt, so if your site gets really busy, you should set up your own instance (we can help you, and the code is on GitHub). But when you're setting your site up to begin with, you can usually get it running using one of our MapIt servers.
In your conf/general.yml
file, point
MAPIT_URL
at the global MapIt server.
Find the areas you need by looking on the
global MapIt website or the
UK one. You must also nominate
the types of area these are (effectively the level of admin
boundary it is), and the generation. On global, the area types look
something like [ 'O05', 'O06' ]
. (Note those contain capital
letter O followed by digits). To determine what types you need, look for
the codes marked “Administrative Boundary Levels” that MapIt
returns — for example, here's
global
MapIt's data for Zurich.
The UK MapIt types are different. For example, for UK FixMyStreet, we use:
MAPIT_TYPES: [ 'DIS', 'LBO', 'MTD', 'UTA', 'CTY', 'COI', 'LGD' ]
which covers all the UK council types (for example, DIS
is district council,
CTY
is county council).
Finally, limit your installation to the specific areas you're interested
in (otherwise you'll be getting areas from the whole world). Identify the
specific areas you want to use, and list them explicitly in
MAPIT_ID_WHITELIST
.
You should also set
MAPIT_GENERATION
,
so that your areas can still be found when we update the global MapIt data.
MAPIT_URL: 'http://global.mapit.mysociety.org'
MAPIT_TYPES: ['O06','O07']
MAPIT_ID_WHITELIST: ['12345','345432','978638']
MAPIT_GENERATION: 3
Ideally, if you can source the data from your local government (which means it's definitive), then it's great if you can add it (as admin boundary data) to the OpenStreetMap project. Our global MapIt will subsequently import it and your FixMyStreet can then use it as described in the previous example. If you're going to do that, the data must be open data and you should probably ask about it on the OSM import list first. Of course, if you do this then anyone else in the world who wants the data will be able to use it too, which is why we encourage this approach.
But if you can't do that, or the boundary data you have is not definitive, you can create your own. Use any good GIS software to plot the boundaries accurately, and then export it as KML shape files. MapIt can import these, so you can then either run your own MapIt instance, or ask us to add it to our custom one.