[OSM-dev] Quick way to remove specific nodes/ways/relations with osmium?

Jochen Topf jochen at remote.org
Thu Mar 11 16:48:59 UTC 2021


Hi!

there is a command to do the opposite of what you ask for: getid. With
"osmium getid" you can get all the objects with the specified ids from
the input file. That's simple and very fast and it can read lists of
ids from a file. But it will not remove the objects with the ids you
list but keep those.

Because the lists of ids to remove is the "inverse" of the list to keep,
it is reasonably straightforward to create one from the other using your
preferred tools. You can use the "comm" command line tool for this. All
you need for this is a list of all ids in the file which you can get
with something like "osmium cat FILE.osm.pbf -f opl | cut -d' ' -f1".
Or maybe your pyosmium program can just create the right list for
"osmium getid" in the first place.

Jochen

On Thu, Mar 11, 2021 at 09:38:04AM -0500, Craig Durkin wrote:
> Date: Thu, 11 Mar 2021 09:38:04 -0500
> From: Craig Durkin <craigdurkin at gmail.com>
> To: dev at openstreetmap.org
> Subject: [OSM-dev] Quick way to remove specific nodes/ways/relations with
>  osmium?
> 
> Hi OSM folks -- I'm a regular user of Osmium for doing some filtering of
> bicycle-accessible ways in OSM as part of an app I'm making. There are
> plenty of tags (bicycle=no, bicycle=sidepath, etc.) that I can successfully
> filter with "osmium tags-filter", but is there a similar way to filter by
> OSM ID?
> 
> There are specific ways that are correctly tagged on OSM as being bicycle
> accessible, but my users would like them removed from the app for various
> reasons, so changing the tagging on OSM would not be the right way to
> achieve this.
> 
> I have created a basic solution with pyosmium that reads a file and then
> writes only those nodes/ways/relations that aren't in a 'forbidden' list,
> but it is quite slow compared to native osmium commands, especially with
> country-sized extracts.
> 
> Is there a way to do something like "osmium id-filter w12134567", or should
> I just upgrade my tool to C and use libosmium instead?
> 
> Thanks,
> Craig

> _______________________________________________
> dev mailing list
> dev at openstreetmap.org
> https://lists.openstreetmap.org/listinfo/dev


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



More information about the dev mailing list