back to the OSM tools main page
spatialite_osm_filter
Syntax:usage: spatialite_osm_filter ARGLIST ============================================================== -h or --help print this help message -o or --osm-path pathname the OSM-XML (output) file path -w or --wkt-mask-path pathname path of text file (WKT mask) -d or --db-path pathname the SpatiaLite DB path 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 -jo or --journal-off unsafe (but faster) mode |
Example:
$ spatialite_osm_filter -o filtered.osm -d my_country.sqlite -w my_mask.txt SQLite version: 3.7.11 SpatiaLite version: 3.1.0 OutNodes OutWays OutRelations $ |
the above shown command must be invoked from the shell:
- -o my_country.osm.pbf selects the OSM-XML file path (output).
- -d my_country.sqlite selects the SpatiaLite's DB-file to be connected.
This DB-file is expected to be one previously created by the spatialite_osm_raw tool. - -w my_mask.txt selects the file containing the WKT espression to be used as a spatial filter.
Please note: WKT expression representing complex Polygons can easily be really lenghty.
Using an external file make much more easier passing this argument. - you can eventually add any other DB-related optimization switch, if you think it will be useful.
Want to learn more ? read the DB optimization short note
WKT mask file:
POLYGON((11.05 43.81, 11.08 43.81, 11.08 43.84, 11.05 43.84, 11.05 43.81)) |
In this example we've used a very simple square shape, but you can actually pass any arbitrary areal geometry (e.g. a complex administrative boundary defined by many thousand points, eventually containing internal holes and separate islands).
Notes:
Any Map object stored within the DB-file will be exported if (and only if) at least one of its OSM-Nodes overlaps the given mask. OSM-Ways and OSM-Relations are never split / trucated: if a single OSM-Node referenced by a Way/Relation matches the given mask, then the whole Way/Relation will be exported, including any other Node falling outside the mask.
Once the command succesfully completes its execution, you'll find a brand new OSM-XML file representing the spatially filtered output of the process.
back to the OSM tools main page