Code Monkey home page Code Monkey logo

postcodes-mapit's Introduction

Voronoi Postcodes MapIt

This repository is for a version of MapIt which contains postcode boundaries calculated from the Voronoi diagram of postcode centroids in ONSPD.

For more information see the blog post here:

If you're looking to create a MapIt in your country, work on any of the underlying code, or re-use it as an app in another Django project, you probably want https://github.com/mysociety/mapit instead.

How to generate the data

Create a virtualenv for this project, change into the cloned repository directory and run pip install -r requirements.txt to install the Python package dependencies.

Download the ONSPD

You can get the latest postcode database from mySociety's cache here: http://parlvid.mysociety.org/os/ (which is a bit simpler than getting it from http://geoportal.statistics.gov.uk/). This data is released under the Open Government License v3.

Unpack this under data/ONSPD_NOV_2017

Download the OSM border for the UK and Isle of Man

OpenStreetMap has administrative boundaries for all countries in the world, which you can conveniently get from Global MapIt:

UK: http://global.mapit.mysociety.org/area/958873.html

Isle of Man: http://global.mapit.mysociety.org/area/363367.html

Use the KML link to download KML versions of the boundaries of the UK (place indata/UK.kml) and Isle of Man (place in data/IoM.kml).

Make the fine-grained postcode unit boundaries

To run the script for the entire country, you can do:

bin/make_postcode_shapes.py \
    data/ONSPD_MAY_2017/Data/ONSPD_MAY_2017_UK.csv \
    data/UK.kml \
    data/postcode-kml

Make the higher-level postcode boundaries

You can build polygons for the postcode areas, districts and sectors from the postcode unit boundaries with:

bin/make_postcode_unions.py data/postcode-kml/

Package up the data

To build a bzip2-compressed tar archive of these KML files, you can run:

bin/make-data-archive.sh data/postcode-kml

... which will create the archive as data/voronoi-of-onspd-kml.tar.bz2.

Import the data into MapIt

To import the data into MapIt, you can run:

./manage.py mapit_UK_import_inaccurate_postcode_areas data/postcode-kml 1

... where 1 is the ID of the MapIt Generation you want to import the areas into. (It won't try to reimport any areas that already exist in that generation.)

You should also import the ONSPD so that you can do lookups by postcode on the front page:

./manage.py mapit_UK_import_onspd \
    --crown-dependencies=include \
    --northern-ireland=include \
    data/ONSPD_MAY_2017/Data/ONSPD_MAY_2017_UK.csv

postcodes-mapit's People

Contributors

matthewgthomas avatar mhl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.