Hi Andrew,

thank you for your clear elaboration on how Osmosis works. The
understanding of Osmosis I got after reading the manual is exactly the same
as you explain it; the data flows through a series of pipelines, and each
filter-task is carried out one after another, and in the order specified in
the command. Indeed it is not mentioned explicitly in the manual how AND
and OR are specified, however using my common sense I made it up myself. I
am happy to see I got the correct understanding on how Osmosis works.

Now for the reasing I made this 3-step command is because I had first
executed the following command in Osmosis:

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

*  --used-node ^  --used-way ^*
  --write-pbf file="D:/GIS Data/Tijdelijk/final.osm.pbf”

However, I ended up with file of about 65 % of the original filesize,
obviously containing a lot of unnecessary data. So I separated each step so
I was able to open the intermediate files in a text-viewer to get a better
understanding of the process, and it worked fine. Now I executed the
command you suggested, and everything also works fine!

However, I now realise I made a big mistake in the command stated above, I
switched the order of the --used-node and --used-way tasks. As Osmosis is
sensitive to order it ended up with first filtering the nodes included in
relations and ways, and thereafter filtering the ways included in
relations, ending up with a lot of unneccessary nodes and properly filtered
ways and relations.

Regards,

Steijn van den Toorn.



2016-02-06 17:07 GMT+01:00 Andrew Byrd <and...@fastmail.net>:

> Hi Steijn,
>
> Osmosis commands set up a pipeline of tasks, and OSM entities (nodes,
> ways, and relations) flow through the stages of the pipeline in order. Your
> series of commands is running three separate very short pipelines, storing
> the intermediate results of each of these pipelines in files. Unless you
> have some use for those intermediate results, you can combine all your
> steps into one long pipeline and skip storing any intermediate results.
>
> Osmosis will automatically connect the pipeline stages together based on
> the order in which you describe them. So all you need to do is remove the
> intermediate write and read tasks:
>
> osmosis ^
>   --read-pbf-fast workers=2 "D:/GIS
> Data/Tijdelijk/portugal-latest.osm.pbf" ^
>   --tf accept-relations boundary=administrative ^
>   --tf accept-relations admin_level=2 ^
>   --used-way ^
>   --used-node ^
>   --write-pbf file="D:/GIS Data/Tijdelijk/final.osm.pbf”
>
> Note that Osmosis applies the pipeline stages in series, not in parallel.
> So you are applying two sequential tag filters, first keeping only
> relations with boundary=administrative, then among those retained relations
> keeping only the ones with admin_level=2. This amounts to a logical AND
> between the two filtering operations: accept only those relations that meet
> both conditions (boundary=administrative and admin_level=2). All other
> entity types flow through these stages untouched. Used-way will then retain
> only the ways referenced in those relations, and used-node will retain only
> the nodes used in those relations and ways. I suspect that this is exactly
> what you want in the output: all the OSM entities necessary to draw level 2
> administrative boundaries.
>
> Looking through questions on Osmosis usage, I am now realizing that there
> is an aspect of the tag-filter task that I did not thoroughly document. Tag
> filters are not limited to a single key-value pair: each tag filter can
> have multiple key-value pairs, and an entity will be accepted or rejected
> when _any_ of them match. This amounts to a logical OR between the supplied
> tag patterns. So you can get a logical OR by listing more than one tag
> pattern in a single tag filter task, and you can get a logical AND by
> specifying multiple sequential tag filter tasks in the pipeline.
>
> Just let me know if anything is unclear.
>
> Regards,
> Andrew Byrd
>
> On 06 Feb 2016, at 02:59, Steijn van den Toorn <steijn...@gmail.com>
> wrote:
>
> Hi,
>
> after spending some days of trial and error I developed the following
> 3-step method to retrieve administrative borders of admin_level 2 (national
> borders). I use Portugal as an example as it is a rather small country (the
> chevrons allow to feed multiple lines into the Windows Command Prompt), but
> I plan to use it more often and on entire Europe and on various
> admin_levels:
>
> Step 1:
> osmosis ^
>   --read-pbf-fast workers=2 "D:/GIS
> Data/Tijdelijk/portugal-latest.osm.pbf" ^
>   --tf accept-relations boundary=administrative ^
>   --tf accept-relations admin_level=2 ^
>   --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/final.osm.pbf"
>
> I read the Osmosis manual thoroughly, but it doesn't get clear to me how I
> can merge, and possibly optimize, these three seperate steps. Any help?
>
> Thanks,
>  Steijn.
> _______________________________________________
> osmosis-dev mailing list
> osmosis-dev@openstreetmap.org
> https://lists.openstreetmap.org/listinfo/osmosis-dev
>
>
>
_______________________________________________
osmosis-dev mailing list
osmosis-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/osmosis-dev

Reply via email to