Dear all, I am new to GIS. I am working with OSM.PBF files for a country, which I downloaded from geofabrik.de. I have a list of nodes, identified by their corresponding coordinates which I would like to remove from the file - basically these nodes correspond to roads and I want to measure travel times for past periods, before these roads were build. If deleting nodes is too difficult, editing their tag to something like "avoid" should also do the trick. I would then like to save these edited files in OSM.PBF format (the program I am using in the next stage requires the files in this format). Currently I am using Python to do this, but am a bit stuck. Would appreciate if somebody could point me to some samples of code editing tags of a node, or deleting nodes. Also, are there easier ways to do this than Python? Thank you very much in advance! I can provide some more info if this is not very clear. Ana asked 29 Jan '19, 13:54 Ana Moura |
You cannot simply remove nodes as this would have undesirable consequences for the ways (roads) using these nodes. You will have to find the IDs of the ways you want to remove. One possible option to remove certain ways from an .osm.pbf file is:
answered 29 Jan '19, 14:30 Frederik Ramm ♦ Thank you very much @Frederik Ramm, that makes a lot of sense! I will try to implement it. Just one follow-up question: is there a smart way to go from node coordinates to way IDs? I collected all these nodes that I wanted to remove. I understand that instead I should remove the ways that they compose. These are identified by an OSM ID but it is not straightforward to me how to obtain the ID. Thanks again!
(29 Jan '19, 16:33)
Ana Moura
In the .opl file, for each way there will be a list of all the nodes it uses. This list looks like so:
(29 Jan '19, 17:15)
Frederik Ramm ♦
1
Osmium also has the handy "osmium getparents" command which allows you, among other things, to find all ways referencing some nodes. Of course, if you know Python, you can also use PyOsmium to do these things. This example: https://github.com/osmcode/pyosmium/blob/master/examples/filter_coastlines.py should give you some hints.
(30 Jan '19, 06:57)
Jochen Topf
|