The are a few tools, which ingest OSM ways ids, but there is no tool to get them from a ".osm" file. Is there any tool (pyosmium?) to print all ways ids from a osm file containing ways, nodes and relations? asked 09 Mar '18, 08:55 landuse aseerel4c26 ♦ |
If the file is not too big you can use xmlstarlet:
The problem with this program is that it uses lots of RAM and with the usual OpenStreetMap osm files it easily fills up the RAM of an average desktop PC without even producing any output. Otherwise there is osmium, a command tool which can print IDs on the standard output; then you have to filter what you need with awk/sed:
answered 12 Mar '18, 14:49 MarcoR |
A command-line tool such as "grep" will get you a list - is that what you want? What OS are you running?
Linux of course
grep "<way" my-osm-file.osm | cut -d\" -f2
Processing XML with the usual unix text processing tools always feels like doing things wrong, but then again, I'm not aware of a tool that does it better in a "pure XML" way. Is there one? There ought to be some sort of grep-like tool that takes XPath expressions...
The problem with actually trying to parse the XML is that you potentially have to load a very large amount of data to do so. There are XML processors around, but trying to do it that way will be much slower and more complicated that the way described above.
If on the other hand you wanted a list of "ways with a certain tag", then the answer might be different.