Thought I had better write all this down so as to not lose it…

  • Install Postgres latest version
  • Install with the spatial extension
  • Create a database – using the pgAdmin tool
  • Set up spatial postgis stuff (not sure how much of this is required but I needed to get the spatial-ref imported according to this) as I was getting an error AddGeometryColumn():
    • postgis.sql
    • postgis_comments.sql
    • spatial_ref_sys.sql
    • rtpostgis.sql
    • raster_comments.sql
    • topology/topology.sql
    • topology_comments.sql

    I got this from here.

  • Download osm2pgsql.
  • Download this style file and put it somewhere handy.
  • Execute
    osm2pgsql -c -d gis -S Default.style -U postgres -Hlocalhost -P 5432 wiltshire-latest.osm.pbf

    The “-S Default.style” refers to the path and name of the style file downloaded above and wherever it was saved to. This resulted in the following output:

    release notes: 'Windows version built by Dominik Perpeet (http://www.customdebug.com/osm2pgsql/index.html)'
    Using projection SRS 900913 (Spherical Mercator)
    Setting up table: planet_osm_point
    NOTICE:  table "planet_osm_point" does not exist, skipping
    NOTICE:  table "planet_osm_point_tmp" does not exist, skipping
    Setting up table: planet_osm_line
    NOTICE:  table "planet_osm_line" does not exist, skipping
    NOTICE:  table "planet_osm_line_tmp" does not exist, skipping
    Setting up table: planet_osm_polygon
    NOTICE:  table "planet_osm_polygon" does not exist, skipping
    NOTICE:  table "planet_osm_polygon_tmp" does not exist, skipping
    Setting up table: planet_osm_roads
    NOTICE:  table "planet_osm_roads" does not exist, skipping
    NOTICE:  table "planet_osm_roads_tmp" does not exist, skipping
    Allocating memory for sparse node cache
    Node-cache: cache=800MB, maxblocks=102401*zd, allocation method=8192
    Mid: Ram, scale=100
    
    Reading in file: wiltshire-latest.osm.pbf
    Processing: Node(769k 769.1k/s) Way(67k 13.46k/s) Relation(490 490.00/s)  parse time: 7s
    
    Node stats: total(769112), max(2147189252) in 1s
    Way stats: total(67298), max(239618172) in 5s
    Relation stats: total(490), max(3228849) in 1s
    Committing transaction for planet_osm_point
    Committing transaction for planet_osm_line
    Committing transaction for planet_osm_polygon
    Committing transaction for planet_osm_roads
    
    Writing way (67k)
    Committing transaction for planet_osm_point
    Committing transaction for planet_osm_line
    Committing transaction for planet_osm_polygon
    Committing transaction for planet_osm_roads
    
    Writing relation (490)
    node cache: stored: 769112(100.00%), storage efficiency: 50.00% (dense blocks: 0, sparse nodes: 769112), hit rate: 73.71%
    Sorting data and creating indexes for planet_osm_point
    Analyzing planet_osm_point finished
    Copying planet_osm_point to cluster by geometry finished
    Creating indexes on  planet_osm_point finished
    All indexes on  planet_osm_point created  in 1s
    Completed planet_osm_point
    Sorting data and creating indexes for planet_osm_line
    Analyzing planet_osm_line finished
    Copying planet_osm_line to cluster by geometry finished
    Creating indexes on  planet_osm_line finished
    All indexes on  planet_osm_line created  in 3s
    Completed planet_osm_line
    Sorting data and creating indexes for planet_osm_polygon
    Analyzing planet_osm_polygon finished
    Copying planet_osm_polygon to cluster by geometry finished
    Creating indexes on  planet_osm_polygon finished
    All indexes on  planet_osm_polygon created  in 1s
    Completed planet_osm_polygon
    Sorting data and creating indexes for planet_osm_roads
    Analyzing planet_osm_roads finished
    Copying planet_osm_roads to cluster by geometry finished
    Creating indexes on  planet_osm_roads finished
    All indexes on  planet_osm_roads created  in 0s
    Completed planet_osm_roads
    
    Osm2pgsql took 18s overall
Setting up postgres and postgis