In the UK we are very fortunate to have the Ordnance Survey who provide the whole of Britain in vector format. The data is provided as over 60 tiles, each of which contains something like 16 shapefiles for each feature type. Each shapefile is prefixed with the tile ID.

There are very good threads here already that deal with the general case for importing all this lovely data into Postgis. For example:

find . -name *.shp -exec ogr2ogr -f PostgreSQL PG:'dbname=my-gis-database 
  active_schema=public host=localhost user=postgres password=my-password' '{}' -s_srs 
  EPSG:27700 -a_srs EPSG:27700 -overwrite -skipfailures -progress \;

My question is this. Is it possible to import all of the data in one simple script like this so that:

  • Each tile inherits from a parent table e.g. HP_rivers INHERITS (rivers)
  • The tablespace is provided to ensure it all loads onto a disk big enough to take it all in one go rather than my small but speedy SSD

My goal is to have a single table structure which allows me to interrogate the whole of Britain or from a given tile, and to store the whole structure on a tablespace on slower but bigger disk.

Any ideas very gratefully received!


Having done this with Vector Map District from MySociety http://parlvid.mysociety.org:81/os/ as in Lat/Lng WGS84, in shapefile format and no login/email required.

Simply downloaded the entire dataset and used ArcGIS (can be also done in QGIS) merged the files together - one big shapefile with attributes including the original tile name (important later). Loaded these shapefiles into PostGIS 2.0 with PgAdmin III and the bulk shapefile loader

see: Bulk load multiple shapefiles into PostGIS

enter image description here

Then the data is in a seamless database and the queries can still pull out by tile as have maintained the attributes with tile number. The reason for merging the data together is for routing which postgres/postgis and pgrouting is very efficient routable network for Great Britain.

TimeStamp your data makes updating much easier at a later date.

  • Thanks - this gave me the final hint I needed. I used a variant of this in the end, moving each feature type one at a time (so all the roads, followed by all the rivers, etc). This allowed me to alter the TABLESPACE as each ended, freeing up space for the next - I haven't found a way of using ogr2ogr or shp2psql allows you to specify the TABLESPACE. – Adrian Jun 6 '12 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.