[OSM-dev] Quick way to remove specific nodes/ways/relations with osmium?
Craig Durkin
craigdurkin at gmail.com
Thu Mar 11 21:26:50 UTC 2021
Ah, good idea! My backup plan was to create a fake OSM changeset file to
apply to PBF tiles to tag every way I wanted to remove with a "deleted=yes"
tag or somesuch, so that I could then filter them with "osmium
tags-filter". Your way seems simpler :)
It's amazing how long you can use unixy systems and still discover new
tools...I hadn't heard of 'comm' before.
Thanks,
Craig
On Thu, Mar 11, 2021 at 11:49 AM Jochen Topf <jochen at remote.org> wrote:
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20210311/e1001275/attachment.htm>
More information about the dev
mailing list