Skip to content

Instantly share code, notes, and snippets.

@iainbeeston
Forked from ismasan/mapit.mkd
Last active December 27, 2015 18:29
Show Gist options
  • Save iainbeeston/7369712 to your computer and use it in GitHub Desktop.
Save iainbeeston/7369712 to your computer and use it in GitHub Desktop.

clone from git

git clone git@github.com:New-Bamboo/mapit.git
cd mapit
git checkout which-care

install setuptools

https://pypi.python.org/pypi/setuptools#installation-instructions

wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
sudo python ez_setup.py

install pip

sudo easy_install pip

you might need to

pip install numpy
brew install gdal postgresql memcached postgis libgeoip

install virtualenv

pip install virtualenv
virtualenv .venv
source .venv/bin/activate

install requirements

pip install -r requirements.txt

set up postgres/postgis

On heroku postgis is only available on the production-level plans (crane/$50per month and above)

createdb mapit
pgsql mapit
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;

Migrate database

All python commands should be prefixed by "foreman run"

./manage.py syncdb
./manage.py migrate mapit

Set up static assets

Set DEBUG to False in conf/general.yml.

./bin/mapit_make_css
mkdir ./staticfiles
./manage.py collectstatic

run server

foreman start

import data

Download and extract the following files from http://parlvid.mysociety.org:81/os/ into ./data

  • ONSPD (as ./data/ONSPD.csv)
  • Boundary line (as ./data/Boundary-Line/)
  • Code point open (as ./data/Code-Point-Open/)

To import them

./manage.py mapit_generation_create --commit --desc "Initial import."
./manage.py loaddata uk
./manage.py mapit_UK_import_boundary_line \
  --control=mapit.controls.first-gss --commit \
  `ls ./data/Boundary-Line/Data/*.shp|grep -v high_water`
./manage.py mapit_UK_find_parents
./manage.py mapit_UK_import_codepoint ./data/Code-Point-Open/Data/CSV/*.csv
./manage.py mapit_UK_scilly ./data/Code-Point-Open/Data/CSV/tr.csv
./manage.py mapit_UK_import_nspd_ni_areas
./manage.py mapit_UK_import_nspd_ni ./data/ONSPD.csv
./manage.py mapit_UK_import_nspd_crown_dependencies ./data/ONSPD.csv
./manage.py mapit_generation_activate --commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment