Geobase/More details on import process
This page contains outdated information. |
Note, these notes have been merged into Main GeoBase import page
GeoBase Import, step by step process (Linux).
Create a file with a WKT for the chosen tile. E.g. 092g07.txt:
POLYGON((-122.5 49.25,-123 49.25,-123 49.5,-122.5 49.5,-122.5 49.25))
This page uses "gis" for database name.
Add spatial references:
psql gis < /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql
Download GeoBase NRN data as both GML and SHP from GeoBase
Use JOSM to download desired area of interest (make sure it includes the chosen NTS tile, e.g. josm --download=49.25,-123,49.5,-122.5). Save as .osm, e.g. 092g07.osm.
Load osm into postgis ("gis" database):
cp /path/to/osm2pgsql/default.style . osm2pgsql -l -d gis 092g07.osm
Load GeoBase NRN shapefile into postgis. Example for BC:
shp2pgsql -s 4326 NRN_BC_6_0_ROADSEG nrn_roadseg |psql -d gis -f - >import.out 2>&1
Define functions that are described in Creating OSM and NRN Shapefiles with PostGIS (one can just pipe the definitions to psql -d gis).
Export NRN and OSM data for the tile as shapefile:
pgsql2shp -f OSM.shp gis "select * FROM select_osm_roadtile('SRID=4326;POLYGON((-122.5 49.25,-123 49.25,-123 49.5,-122.5 49.5,-122.5 49.25))')" pgsql2shp -f NRN.shp gis "select * FROM select_nrn_roadtile('SRID=4326;POLYGON((-122.5 49.25,-123 49.25,-123 49.5,-122.5 49.5,-122.5 49.25))')"
Load shapes in RoadMatcher. If there are errors in OSM geometry that prevent RoadMatcher from working, fix those in JOSM, upload and repeat osm import. It may take a couple iterations to fix the errors.
Run geobase2osm, e.g.
geobase2osm.py -o out.osm -b 092g07.txt -e Result.jml -i NRN_BC_6_0_GEOM.gml
It's a good idea to look at the resulting .standalone.osm file in JOSM before uploading.
Finally, use bulk_upload.py to upload resulting data:
bulk_upload.py -i out.osm.standalone.osm -u username -p password -c 'geobase nrn import'
Expect to be fixing a lot of topology errors where OSM and NRN datasets meet after the import.