[OSM-dev] Area handling in pyosmium/libosmium

Jochen Topf jochen at remote.org
Wed May 17 20:43:44 UTC 2017


On Wed, May 17, 2017 at 08:22:09PM +0000, Andrey Novikov wrote:
> I want to switch to pyosmium for data manipulation. I've read that it
> nicely creates area objects from relations. But I didn't find in
> documentation how to filter what relations and ways to process. I've read
> how to filter them for my own purposes but I'm afraid that it processes all
> relations to construct areas. I need to extract only a subset of them so I
> do not want to waste time for processing of unwanted data.

Currently pyosmium/libosmium can only create all areas and you have to
filter afterwards. The reason is that without creating all areas,
old-style multipolygon relations (with tags on the outer ways instead of
on the relations) can not be handled correctly. Now that old-style
multipolygon relations are gone, I am working on changing this to allow
filtering beforehand.

That being said, the assembly of the multipolygon isn't that expensive.
On my, admittedly beefy, server, it takes about 20 minutes for the whole
planet to assemble all multipolygon (and boundary) relations. The bigger
problem is the memory use.

Until a better solution is available, another option for you might be to
first use osmium-tool (http://osmcode.org/osmium-tool/) to filter out
some relations by tags
(http://docs.osmcode.org/osmium/latest/osmium-tags-filter.html) and then
run this through your pyosmium program assembling the areas.

Jochen Topf  jochen at remote.org  https://www.jochentopf.com/  +49-351-31778688

More information about the dev mailing list