OSMIUM-GETID(1)
β¨ osmium-getid β¨
okay bestie, welcome to osmium-getid(1) β the section 1 man page that lets you pull specific objects out of an OSM file by their ID. it's giving "targeted extraction, main character energy" π
NAME π
osmium-getid β get objects from an OSM file by ID. literally that's it, that's the whole vibe. π¦
SYNOPSIS πΈ
osmium getid [OPTIONS] OSM-FILE ID...
osmium getid [OPTIONS] OSM-FILE -i ID-FILE
osmium getid [OPTIONS] OSM-FILE -I ID-OSM-FILE
DESCRIPTION π
So like, you want objects with specific IDs from the input, and you want them written to the output. That's the whole deal. β¨
The IDs can come from three places, bestie:
- on the command line (that's the first synopsis case),
- from text files with one ID per line (second case),
- or from OSM files (third case).
And yes you can mix them β no rules against it. π
All objects with those IDs get read from OSM-FILE and written to the output. If you use --add-referenced/-r, then every object referenced by those objects also gets added to the output too. Obsessed. π«Ά
Objects get written out in the order they are found in the OSM-FILE. Not sorted, not reordered, just vibes as found.
Here's the tea on how many times your file gets read π: if --add-referenced/-r is not used, the input file is read only once. If it is used, the input file will possibly be read up to three times. Just so you know what you're signing up for.
On the command line or in the ID file, the IDs look like: TYPE-LETTER NUMBER. The type letter is n for nodes, w for ways, and r for relations. No type letter at all? Then n for nodes is assumed (or whatever the --default-type option says, iykyk). So "n13 w22 17 r21" will match the nodes 13 and 17, the way 22 and the relation 21. Slay. π
The order in which the IDs appear does not matter. Identical IDs can appear multiple times on the command line or in the ID file(s) β nobody's checking, nobody's judging. π
On the command line, your list of IDs can be in separate arguments, or crammed into a single argument separated by spaces, tabs, commas (,), semicolons (;), forward slashes (/) or pipe characters (|). Pick your fighter. π₯
In an ID file (that's the --id-file/-i option), each line must start with an ID in the format described above. Leading space characters in the line are ignored. Lines can optionally contain a space character or a hash sign (#) after the ID, and any characters after that are ignored. (This is also what lets you read files in OPL format. iconic.) Empty lines are ignored too. β¨
β οΈ Note that all objects will be taken from the 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. So don't get it twisted.
The OSM-FILE can not be a history file unless the --with-history/-H option is used. Then all versions of the objects will be copied to the output.
If referenced objects are missing from the input file, the type and IDs of those objects is written out to STDERR at the end of the program β unless the --with-history/-H option was given.
π¨ Also: this command will not work with negative IDs. periodt.
OPTIONS β¨
--default-type=TYPEβ Use TYPE (node,way, orrelation) for IDs without a type prefix (default:node). You're also allowed to just use the first character of the type here, because we're chill like that. π-H,--with-historyβ Make this program work on history files. This is only needed when using the-roption. π-i,--id-file[=FILE]β Read IDs from a text file instead of from the command line. Use the special name-to read fromSTDIN. Each 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 β this character and all following characters are ignored. (This allows files in OPL format to be read. π¦) Empty lines are also ignored. This option can be used multiple times. π₯-I,--id-osm-file=OSMFILEβ Like--id-file/-ibut get the IDs from an OSM file. This option can be used multiple times. πΈ-r,--add-referencedβ Recursively find all objects referenced by the objects of the given IDs and include them in the output. This only works correctly on non-history files unless the-Hoption is also used. β-t,--remove-tagsβ Remove tags from objects that are not explicitly requested but are only included to complete references (nodes in ways and members of relations). If an object is both requested and used as a reference it will keep its tags. You also need--add-referenced/-rfor this to make sense. π--verbose-idsβ Also print all requested and missing IDs. This is usually disabled, because the lists can get quite long. (This option implies--verbose.) π
COMMON OPTIONS π
-h,--helpβ Show usage help. π«Ά-v,--verboseβ Set verbose mode. The program will output information about what it is doing toSTDERR.--progressβ Show progress bar. Usually a progress bar is only displayed ifSTDOUTandSTDERRare detected to be TTY. With this option a progress bar is always shown. Note that a progress bar will never be shown when reading fromSTDINor a pipe. π--no-progressβ Do not show progress bar. Usually a progress bar is displayed ifSTDOUTandSTDERRare detected to be a TTY. With this option the progress bar is suppressed. Note that a progress bar will never be shown when reading fromSTDINor a pipe. πΈ
INPUT OPTIONS π
-F,--input-format=FORMATβ The format of the input file(s). Can be used to set the input format if it can't be autodetected from the file name(s). This will set the format for all input files, there is no way to set the format for some input files only. Seeosmium-file-formats(5)or the libosmium manual for details. β¨
OUTPUT OPTIONS π
-f,--output-format=FORMATβ The format of the output file. Can be used to set the output file format if 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. πΎ--generator=NAMEβ The name and version of the program generating the output file. It will be added to the header of the output file. Default is"osmium/"and 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 will refuse to write over an existing file. π--output-header=OPTION=VALUEβ Add output header option. This command line option can be used multiple times for different OPTIONs. See theosmium-output-headers(5)man page for a list of available header options. For some commands you can use the special format"OPTION!"(ie. an exclamation mark after the OPTION and no value set) to set the value to the same as in the input file. π
DIAGNOSTICS π¨
osmium getid exits with exit code:
0β if all IDs were found. π1β if there was an error processing the data or not all IDs were found, (this is only detected if the--with-history/-Hoption was not used). π2β if there was a problem with the command line arguments. π
MEMORY USAGE π§
osmium getid does all its work on the fly and only keeps a table of all IDs it needs in main memory. efficient queen. π
EXAMPLES π
Output nodes 17 and 1234, way 42, and relation 111 to STDOUT in OPL format:
osmium getid -f opl planet.osm.pbf n1234 w42 n17 r111
SEE ALSO π
osmium(1),osmium-getparents(1),osmium-removeid(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> β they don't bite, fr fr. π«Ά
AUTHORS π
Jochen Topf <jochen@topf.org>.
and that's the whole page bestie π this was osmium-getid, version 1.19.1, from the OSMIUM-GETID(1) manual β go forth and extract those objects, you absolute icon β¨π
π¦ 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