I am trying to filter administrative boundaries of admin_level 4. I carefully read the Osmosis reference and some examples, and composed the following query (the chevrons allow to feed multiple lines into the Windows Command Prompt):

osmosis ^
  --read-pbf-fast workers=2 "D:/GIS Data/Data/netherlands-latest.osm.pbf" ^
  --tf accept-relations boundary=administrative ^
  --tf accept-relations admin_level=4 ^
  --tf reject-ways ^
  --tf reject-nodes ^
  --used-way ^
  --used-node ^
  --write-pbf omitmetadata=true file="D:/GIS Data/Tijdelijk/provinciestestosmosis.osm.pbf"

This works fine in the sense that it yields all the required relations (checked the OSM file manually). However, no ways of nodes are included, which is not what I wanted as I need them to plot the administrative boundaries. It seemed an obvious error to me as I first accept the required relations, then reject all ways and nodes, leaving Osmosis unable to resolve the used ways and nodes in the relations.

Then did the following, however this yields the same result:

osmosis ^
  --read-pbf-fast workers=2 "D:/GIS Data/Data/netherlands-latest.osm.pbf" ^
  --tf accept-relations boundary=administrative ^
  --tf accept-relations admin_level=4 ^
  --used-node ^
  --tf reject-ways ^
  --tf reject-nodes ^
  --write-pbf omitmetadata=true file="D:/GIS Data/Tijdelijk/provinciestestosmosis.osm.pbf"

Then did the following:

osmosis ^
  --read-pbf-fast workers=2 "D:/GIS Data/Data/netherlands-latest.osm.pbf" ^
  --tf accept-relations boundary=administrative ^
  --tf accept-relations admin_level=4 ^
  --tf accept-ways ^
  --tf accept-nodes ^
  --used-ways ^
  --used-node ^
  --write-pbf omitmetadata=true file="D:/GIS Data/Tijdelijk/provinciestestosmosis.osm.pbf"

However this yields an enormous result (700 MB PBF file), including far more data then is neccessary for the selected relations. Can someone please elaborate on how to exactly read the Osmosis queries and show an example of what is the correct query (relations:admin_level=4 including depending sub-relations, ways and nods)?

BTW: This question is related to my question about Osmfilter.

asked 05 Feb '16, 02:43

Steijn's gravatar image

Steijn
61569
accept rate: 0%

edited 05 Feb '16, 03:40

I did run another query:

osmosis ^
  --read-pbf-fast workers=2 "D:/GIS Data/Data/netherlands-latest.osm.pbf" ^
  --tf accept-relations boundary=administrative ^
  --tf accept-relations admin_level=4 ^
  --used-way ^
  --used-node ^
  --write-pbf omitmetadata=true file="D:/GIS Data/Tijdelijk/provinciestestosmosis.osm.pbf"

This again results in a very large PBF file (700 MB PBF file), clearly contains far more data than needed. :(

(05 Feb '16, 21:52) Steijn

meta: please could you add this as a "new comment" instead if it is no "answer" to the original question? :-) Or edit your original question text and add it there.

(06 Feb '16, 10:21) aseerel4c26 ♦

Conversion from answer to comment done.

@Stejin: we are happy when you pay attention to this hint from aseerel4c26.

(06 Feb '16, 10:49) stephan75

The following works correct. First filter the relations (step 1), then filter the ways (step 2) en then filter the nodes (step 3). I must say, Osmosis is not a very straight forward tool to use.

Step 1:

osmosis ^
  --read-pbf-fast workers=2 "D:/GIS Data/Tijdelijk/netherlands-latest.osm.pbf" ^
  --tf accept-relations boundary=administrative ^
  --tf accept-relations admin_level=4 ^
  --write-pbf file="D:/GIS Data/Tijdelijk/step1.osm.pbf"

Step 2:

osmosis ^
  --read-pbf-fast workers=2 "D:/GIS Data/Tijdelijk/step1.osm.pbf" ^
  --used-way ^
  --write-pbf file="D:/GIS Data/Tijdelijk/step2.osm.pbf"

Step 3:

osmosis ^
  --read-pbf-fast workers=2 "D:/GIS Data/Tijdelijk/step2.osm.pbf" ^
  --used-node ^
  --write-pbf file="D:/GIS Data/Tijdelijk/step3.osm.pbf"

Are there any suggestions on how to improve the rather tedious method? :)

permanent link

answered 06 Feb '16, 00:21

Steijn's gravatar image

Steijn
61569
accept rate: 0%

edited 06 Feb '16, 00:22

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×203
×69

question asked: 05 Feb '16, 02:43

question was seen: 3,114 times

last updated: 06 Feb '16, 10:49

powered by OSQA