You are on page 1of 4

Osmosis/Examples - OpenStreetMap Wiki

Create account Log in

Page Discussion

Read View source View history

Go

Search

Search

Osmosis/Examples
< Osmosis
site
Main Page


Available languages

Help

Special pages

Deutsch English
Other languages Help us translating this wiki
Afrikaans Alemannisch

asturianu azrbaycanca
bosanski brezhoneg catal etina corsu dansk

eesti espaol Esperanto euskara franais Frysk


Gaeilge Gidhlig galego
Hausa
hrvatski Igbo
Bahasa Indonesia interlingua isiXhosa isiZulu slenska italiano Basa Jawa

Kiswahili Kreyl ayisyen Kryl gwadloupyen Kurd


latvieu
Ltzebuergesch lietuvi magyar Malagasy
Malti
Bahasa Melayu Baso Minangkabau
Nederlands
norsk bokml norsk nynorsk occitan
Oromoo ozbekcha

polski portugus portugus do Brasil romn shqip


slovenina slovenina Soomaaliga / srpski suomi svenska

Trke Vahcuengh Ting Vit Wolof Yorb Zazaki


Printable version

This page gives some more complex examples. See Osmosis#Example Usage for more

The map
Map Features
Contributors
Help
Blogs
Shop
Donations
Recent changes
Tools
What links here
Related changes

Permanent link

examples. For reference documentation of the various options see Osmosis/Detailed Usage

Page information
Cite this page

Contents
1 Misc. examples
2 Extract administrative Boundaries from a PBF Extract
3 Breaking OSM file into several bounding boxes
4 Breaking out a large number of polygons
5 Breaking out just one polygon

Misc. examples
Setting up a local database copy with minutely diffs
User:EdLoach has documented the commands he uses to maintain a local extract from
the minutely updates.
Tutorial: A Self-Updating Local OpenStreetMap Extract - shows various osmosis
reading, writing, filtering and replication tasks in a real world use case.
User:Firefishy/za-rail-script - setting up replication within a bash script

Extract administrative Boundaries from a PBF Extract


The following will create an extract that only consists of administrative boundaries within a
specifieed polygon.

osmosis --read-pbf file=ohio.osm.pbf --boundingpolygon file=input.poly --tf accept-ways


boundary=administrative --used-node --write-xml
http://wiki.openstreetmap.org/wiki/Osmosis/Examples[2015-04-14 11:07:14]

Osmosis/Examples - OpenStreetMap Wiki

output.osm

Breaking OSM file into several bounding boxes


The following command line breaks Slovenia OSM into four "quadrants" around lat=15,
long=46 axis:

osmosis
--read-xml SloveniaGarmin.osm --tee 4
--bounding-box left=15 top=46 --write-xml
SloveniaGarminSE.osm
--bounding-box left=15 bottom=46 --write-xml
SloveniaGarminNE.osm
--bounding-box right=15 top=46 --write-xml
SloveniaGarminSW.osm
--bounding-box right=15 bottom=46 --write-xml
SloveniaGarminNW.osm
(NOTE: the order of operations is important. This sample works for Osmosis version 0.29)
If you have more than 20 bboxes, you should use bboxSplit instead. It is much faster an
uses a lot less memory when working with the complete planet.

Breaking out a large number of polygons


The following command line breaks out 16 individual bz2 files for the German Federal States
(all to be written on one line without the backslashes, or copy/pasted including the
backslashes and no trailing spaces):

osmosis \
--rx full/planet-071128.osm.bz2 \
--tee 16 \
--bp file=polygons/europe/germany/badenwuerttemberg.poly \
--wx baden-wuerttemberg.osm.bz2 \
--bp file=polygons/europe/germany/bayern.poly \
--wx bayern.osm.bz2 \
--bp file=polygons/europe/germany/berlin.poly \
--wx berlin.osm.bz2 \
--bp file=polygons/europe/germany/brandenburg.poly
\
--wx brandenburg.osm.bz2 \
--bp file=polygons/europe/germany/bremen.poly \
--wx bremen.osm.bz2 \
--bp file=polygons/europe/germany/hamburg.poly \
--wx hamburg.osm.bz2 \
--bp file=polygons/europe/germany/hessen.poly \
--wx hessen.osm.bz2 \
http://wiki.openstreetmap.org/wiki/Osmosis/Examples[2015-04-14 11:07:14]

Osmosis/Examples - OpenStreetMap Wiki

--bp file=polygons/europe/germany/mecklenburgvorpommern.poly \
--wx mecklenburg-vorpommern.osm.bz2 \
--bp
file=polygons/europe/germany/niedersachsen.poly \
--wx niedersachsen.osm.bz2 \
--bp file=polygons/europe/germany/nordrheinwestfalen.poly \
--wx nordrhein-westfalen.osm.bz2 \
--bp file=polygons/europe/germany/rheinlandpfalz.poly \
--wx rheinland-pfalz.osm.bz2 \
--bp file=polygons/europe/germany/saarland.poly \
--wx saarland.osm.bz2 \
--bp file=polygons/europe/germany/sachsenanhalt.poly \
--wx sachsen-anhalt.osm.bz2 \
--bp file=polygons/europe/germany/sachsen.poly \
--wx sachsen.osm.bz2 \
--bp file=polygons/europe/germany/schleswigholstein.poly \
--wx schleswig-holstein.osm.bz2 \
--bp file=polygons/europe/germany/thueringen.poly \
--wx thueringen.osm.bz2
If the part "osmosis --rx full/planet-071128.osm.bz2" in the above example doesn't work for
you, use "bzcat full/planet-071128.osm.bz2 |osmosis --rx /dev/stdin" instead of it.
Splitting out 16 polygons takes about 30% more time than splitting out only one.
Performance can be improved by
not using .bz2
first cutting out an Europe or Germany bbox and operating on that
See also: Osmosis/Polygon_Filter_File_Format
See this Geofabrik blog entry

for an extensive example of polygon splitting.

Breaking out just one polygon


For Linux and Windows users, a cheap and really fast method for this specific task would be
to use osmconvert instead of Osmosis. Some examples:

./osmconvert europe.osm -B=hamburg.poly o=hamburg.osm


./osmconvert europe.pbf -B=hamburg.poly o=hamburg.pbf
bzcat europe.osm.bz2 | ./osmconvert - -B=hamburg.poly
|bzip2 >hamburg.osm.bz2
./osmconvert europe.osm.gz -B=hamburg.poly |gzip -1

http://wiki.openstreetmap.org/wiki/Osmosis/Examples[2015-04-14 11:07:14]

Osmosis/Examples - OpenStreetMap Wiki

>hamburg.osm.gz
Note: It is much faster to compress files with gzip -1 than with bzip2. Although the
compressed file will be about 50% larger, the compression process will be up to 10 times
faster.
Categories: Technical

Osmosis

This page was last modified on 18 February 2014, at 16:21.


Content is available under Creative Commons Attribution-ShareAlike 2.0 license unless otherwise noted.
Privacy policy

About OpenStreetMap Wiki

http://wiki.openstreetmap.org/wiki/Osmosis/Examples[2015-04-14 11:07:14]

Disclaimers

You might also like