Modifying way/relation with known id in pbf

Is it possible to use osmfilter to modify way/relation with known id?
I have downloaded pbf file from Geofabrik, and now, in order to be rendered correctly, I have to change tag value of admin_level for some relations.

I am able to drop it by using switch

--drop-relations="@id=123456"

, but

--modify-relation-tags="@id=123456 to admin=4"

doesn’t work :frowning:

Or, is there any other tool that could do this task?

Did you try

--modify-relation-tags="@id=123456 admin_level=2 to =4"

?

You say “in order to be rendered correctly”, which might mean you’re using a postgres database for rendering? If you are, you could just change it in there.

Yes, but it doesn’t work. If there is “and” it looks like that the id clause is ignored :frowning:

For tile server we use postgres and that data are modified directly in database, but that is not the only use of this data. I got the task to prepare pbf with modified data, it is not possible postgres → pbf so I have to do it directly in pbf.

Do you have any idea how it could be done? Maybe to extract elements with osmfilter, modify all extracted elements and than to merge it back into the main pbf ?!?

I’ve used “osmosis” for that sort of thing - here’s an example:

https://github.com/SomeoneElseOSM/SomeoneElse-style/blob/6e671a111b3206c173704e8e5ef718d02c310341/update_render.sh#L190 is an example of a transformation of “name:cy” to “name”, using rules in https://github.com/SomeoneElseOSM/SomeoneElse-style/blob/master/transform_cy.xml . I’m sure you could do something similar with admin levels.

The line above in the script, https://github.com/SomeoneElseOSM/SomeoneElse-style/blob/master/update_render.sh#L188 , extracts a small area of PBF to perform the transformation on and a line further down merges everything together: https://github.com/SomeoneElseOSM/SomeoneElse-style/blob/master/update_render.sh#L206 .

SomeoneElse, Thank you for the idea and for your experience…