OSMIUM-GETPARENTS(1)
π OSMIUM-GETPARENTS β the manual, but make it make sense π
okay bestie, welcome to osmium-getparents(1), the manual page for the osmium getparents command. yes it's a real man page, yes it's from the osmium fam, and yes we're gonna get through it together. grab a snack π
β¨ NAME β¨
osmium-getparents β get parents of objects from an OSM file π«Ά
β¨ SYNOPSIS β¨
osmium getparents [OPTIONS] OSM-FILE ID...
osmium getparents [OPTIONS] OSM-FILE -i ID-FILE
osmium getparents [OPTIONS] OSM-FILE -I ID-OSM-FILE
πΈ DESCRIPTION πΈ
So the whole vibe here: you hand it some IDs, and it goes into the input file and finds every object that references the objects with those IDs, then writes them out. Meaning: it'll grab ways referencing any of your specified node IDs, and relations referencing any specified node, way, or relation IDs. it's giving "who's talking about you" energy π
But β and this is the part people always get wrong β it only resolves one level of indirection. So no relations of relations, and no relations referencing ways that reference your specified node IDs. One hop, that's it, periodt.
Your IDs can come from three places:
- straight up on the command line (first case in the synopsis π)
- read from text files with one ID per line (second case)
- read from OSM files (third case)
and honestly? you can mix and match all three. no rules, live your truth π
All objects with these IDs get read from OSM-FILE and written to the output. And if you throw in the --add-self/-s option, the objects with the specified IDs themselves get added to the output too. main character gets an invite to their own party β¨
Objects get written out in the order they're found in OSM-FILE. Not sorted, not alphabetical, just vibes-in-file-order.
The input file is read only once. efficient queen π
On the command line or in the ID file, IDs look like this: TYPE-LETTER NUMBER. The type letter is n for nodes, w for ways, and r for relations. No type letter? Then n for nodes is assumed β or whatever the --default-type option says. So "n13 w22 17 r21" matches nodes 13 and 17, way 22, and relation 21. lowkey elegant.
The order the IDs appear in does not matter. And identical IDs can show up multiple times on the command line or in the ID file(s) β it's not gonna be weird about it.
On the command line, your ID list can be in separate arguments, or all crammed into a single argument separated by spaces, tabs, commas (,), semicolons (;), forward slashes (/), or pipe characters (|). however you wanna serve it π
In an ID file (--id-file/-i), every line must start with an ID in the format described above. Leading space characters on the line get ignored. Lines can optionally contain a space character or a hash sign (#) after the ID β anything after that is ignored. (This is also how you can read files in OPL format, sneaky.) Empty lines are ignored. clean.
β οΈ Important-ish caveat bestie: all objects get taken from OSM-FILE. The ID-OSM-FILE is only used to detect which objects to get. This might matter if there are different object versions in the different files. don't get caught out π
OSM-FILE can be a history file, and then all matching versions of the objects get copied to the output. love that for you.
And finally: this command will not work with negative IDs. nope. not happening. π
β¨ OPTIONS β¨
--default-type=TYPEβ Use TYPE (node,way, orrelation) for IDs that have no type prefix (default:node). You're also allowed to just use the first character of the type here. shortcuts, we love them.-i,--id-file[=FILE]β Read IDs from a text file instead of from the command line. Use the special name-to read from STDIN. Every line of the file must start with an ID in the format described above. Lines can optionally contain a space character or a hash sign (#) after the ID β that character and everything after it is ignored. (Which, again, lets you read files in OPL format.) Empty lines are also ignored. This option can be used multiple times.-I,--id-osm-file=OSMFILEβ Like-ibut get the IDs from an OSM file instead. Also usable multiple times.-s,--add-selfβ Also add all objects with the specified IDs to the output. yes, them too.--verbose-idsβ Also print all requested IDs. Usually disabled, because these lists can get quite long (fr fr, we're talking huge). This option implies--verbose.
π¦ COMMON OPTIONS π¦
-h,--helpβ Show usage help.-v,--verboseβ Set verbose mode. The program outputs info about what it's doing to STDERR.--progressβ Show a progress bar. Usually a progress bar is only displayed if STDOUT and STDERR are detected to be TTY. With this option it's always shown. Note that a progress bar will never be shown when reading from STDIN or a pipe.--no-progressβ Do not show a progress bar. Usually a progress bar is displayed if STDOUT and STDERR are detected to be a TTY. With this option it gets suppressed. And same deal: a progress bar will never be shown when reading from STDIN or a pipe.
π INPUT OPTIONS π
-F,--input-format=FORMATβ The format of the input file(s). Use this to set the input format when it can't be autodetected from the file name(s). Heads up: this sets the format for all input files β there is no way to set the format for just some of them. Seeosmium-file-formats(5)or the libosmium manual for the deets.
π OUTPUT OPTIONS π
-f,--output-format=FORMATβ The format of the output file. Use this to set the output file format when it can't be autodetected from the output file name. Seeosmium-file-formats(5)or the libosmium manual for details.--fsyncβ Callfsyncafter writing the output file to force flushing buffers to disk. safety first β¨--generator=NAMEβ The name and version of the program generating the output file. It gets added to the header of the output file. Default isosmium/plus the version of osmium.-o,--output=FILEβ Name of the output file. Default is-(STDOUT).-O,--overwriteβ Allow an existing output file to be overwritten. Normally osmium refuses to write over an existing file. (it's protecting you π)--output-header=OPTION=VALUEβ Add an output header option. This command line option can be used multiple times for different OPTIONs. See theosmium-output-headers(5)man page for the list of available header options. For some commands you can use the special formatOPTION!(that's an exclamation mark after the OPTION with no value set) to set the value to the same as in the input file.
π©Ί DIAGNOSTICS π©Ί
osmium getparents exits with exit code:
0β if there was no error. slay.1β if there was an error processing the data. π2β if there was a problem with the command line arguments. π
π§ MEMORY USAGE π§
osmium getparents does all its work on the fly and only keeps a table of all the IDs it needs in main memory. lightweight king π
π EXAMPLES π
Output all ways referencing nodes 17 or 1234, and all relations with nodes 17 or 1234, or way 42, or relation 111 as members, to STDOUT in OPL format:
osmium getparents -f opl planet.osm.pbf n1234 w42 n17 r111
look at that. one line. iconic. π
π SEE ALSO π
osmium(1),osmium-getid(1),osmium-file-formats(5),osmium-output-headers(5)- Osmium website
Β©οΈ COPYRIGHT Β©οΈ
Copyright (C) 2013-2026 Jochen Topf <jochen@topf.org>.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
π¬ CONTACT π¬
If you have any questions or want to report a bug, please go to <https://osmcode.org/contact.html>
π AUTHORS π
Jochen Topf <jochen@topf.org>.
and that's the whole page bestie, you made it π₯³ this was osmium-getparents(1) from version 1.19.1 β go forth, find those parents, and remember: one level of indirection only. mwah ππ¦
π¦ where this page comes from
- fedora 44: osmium-tool 1.19.1-1.fc44 Β· GPL-3.0-only
- nixos 26.05: osmium-tool 1.19.1
- nixpkgs unstable: osmium-tool 1.19.1
- ubuntu stonking: osmium-tool 1.19.1-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms