Skip to content

Instantly share code, notes, and snippets.

@vlprans
Created April 21, 2017 13:57
Show Gist options
  • Select an option

  • Save vlprans/d45a45bc6d2fb9df29e7c03023b2b503 to your computer and use it in GitHub Desktop.

Select an option

Save vlprans/d45a45bc6d2fb9df29e7c03023b2b503 to your computer and use it in GitHub Desktop.
# create DB for extraction of OSM info
docker run -d --name osm-geodb -e POSTGRES_USER=geodb mdillon/postgis:9.6
create extension hstore;
alter system set max_wal_size='4GB';
alter system set shared_buffers='2GB';
alter system set wal_buffers='64MB;'

# import OSM data into postgres
docker run --rm --link osm-geodb:geodb -v /home/idmcore/stuff:/stuff my-osm2pgsql osm2pgsql -d geodb -H geodb -U geodb -p osm -k -l -s -c /stuff/netherlands-latest.osm.bz2

create table osm_zips(zip varchar unique, way geometry);
insert into osm_zips(zip, way)
(select zip, first(way) from
    (select replace(tags->'addr:postcode', ' ', '') as zip, way from osm_point) s
    group by zip);

select count(*) from osm_zips;
 count
--------
 453920
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment