George MacKerron: code blog

GIS, software development, and other snippets

Archive for the ‘GIS’ Category

Using OS Code-Point Polygons in PostGIS

with one comment

Ordnance Survey’s Code-Point with Polygons “provides a precise geographical location for each postcode unit in Great Britain”. It’s available in various formats, including ESRI .shp files.

Many UK academics can access the data via institutional subscription to EDINA Digimap. I’m using it in my research into subjective wellbeing and environmental quality.

This post shows how to:

  1. import the data files into a PostGIS database; and
  2. de-normalise the data into a single table, where there’s a one-to-one mapping of postcodes to rows, and each row contains either all geographical locations covered by a postcode (as a single geometry column, of type multipolygon) or the reason why no such location is available

Read the rest of this entry »

Written by George

November 14th, 2009 at 1:13 pm

Posted in GIS,PostGIS,Ruby,SQL

Importing the National Statistics Postcode Directory into PostGIS

with one comment

This isn’t a very difficult task, but creating the table is somewhat laborious, so perhaps you’ll find the following SQL helpful.

Read the rest of this entry »

Written by George

May 5th, 2009 at 11:19 am

Posted in GIS,PostGIS,SQL