D 2012-05-03T19:11:57.145 L spatialite_osm_net U sandro W 4907 back to the OSM tools main page

spatialite_osm_filter

Syntax:
usage: spatialite_osm_net ARGLIST
==============================================================
-h or --help                    print this help message
-o or --osm-path pathname       the OSM-XML file path
                 both OSM-XML (*.osm) and OSM-ProtoBuf
                 (*.osm.pbf) are indifferenctly supported.
-d or --db-path  pathname       the SpatiaLite DB path
-T or --table    table_name     the db table to be feeded

you can specify the following options as well
-cs or --cache-size    num      DB cache size (how many pages)
-m or --in-memory               using IN-MEMORY database
-2 or --undirectional           double arcs
--roads                         extract roads (default)
--railways                      extract railways
                                (mutually exclusive)
template-file specific options:
-ot or --out-template  path     creates a default template-file
-tf or --template-file path     using a template-file

Example:
$ spatialite_osm_net -o my_country.osm.pbf -d my_country.sqlite -T roads
SQLite version: 3.7.11
SpatiaLite version: 3.1.0
Parsing input: Pass 1 (Nodes and Ways) ...
Parsing input: Pass 2 (Arcs of the Graph) ...
Creating helper table 'roads_nodes' ... wait please ...
        Helper table 'roads_nodes' succesfully created
Dropping temporary table 'osm_tmp_nodes' ... wait please ...
        Dropped table 'osm_tmp_nodes'
Dropping temporary table 'graph_nodes' ... wait please ...
        Dropped table 'graph_nodes'
VACUUMing the DB ... wait please ...
        All done: OSM graph was succesfully loaded
$

the above shown command must be invoked from the shell:
Please note: sometimes you can notice many Unresolved-Node or Unresolved-Way warning messages: dont be too much worried.
This simply means that your OSM input file does actually contains several broken cross-references (i.e. invalid complex Map objects).
This one is a quite common situation, but it's rather innocuous (invalid objects will be simply ignored, fully preserving any other valid object).

Another example:
$  spatialite_osm_net -o my_country.osm.pbf -d my_country.sqlite -T rails --railways
SQLite version: 3.7.11
SpatiaLite version: 3.1.0
Parsing input: Pass 1 (Nodes and Ways) ...
Parsing input: Pass 2 (Arcs of the Graph) ...
Creating helper table 'rails_nodes' ... wait please ...
        Helper table 'rails_nodes' succesfully created
Dropping temporary table 'osm_tmp_nodes' ... wait please ...
        Dropped table 'osm_tmp_nodes'
Dropping temporary table 'graph_nodes' ... wait please ...
        Dropped table 'graph_nodes'
VACUUMing the DB ... wait please ...
        All done: OSM graph was succesfully loaded
$


Once the command succesfully completes its execution, you'll find a brand new DB-file just created ...

db-map.png
... you can explore this DB-file e.g. using spatialite_gui ...

osm-map.png
... or you can connect the DB-file to a more conventional desktop GIS such as QGIS, so to immediately see your map appearing on the screen.

back to the OSM tools main page Z 481a83a7ecd9ea01a20f64765858f90b