1OSMIUM-GETID(1) OSMIUM-GETID(1)
2
3
4
6 osmium-getid - get objects from OSM file by ID
7
9 osmium getid [OPTIONS] OSM-FILE ID...
10 osmium getid [OPTIONS] OSM-FILE -i ID-FILE
11 osmium getid [OPTIONS] OSM-FILE -I ID-OSM-FILE
12
14 Get objects with the given IDs from the input and write them to the
15 output.
16
17 IDs can be given on the command line (first case in synopsis), or read
18 from text files with one ID per line (second case in synopsis), or read
19 from OSM files (third cases in synopsis). A mixture of these cases is
20 also allowed.
21
22 All objects with these IDs will be read from OSM-FILE and written to
23 the output. If the option --add-referenced/-r is used all objects ref‐
24 erenced from those objects will also be added to the output.
25
26 Objects will be written out in the order they are found in the OSM-
27 FILE.
28
29 If the option --add-referenced/-r is not used, the input file is read
30 only once, if it is used, the input file will possibly be read up to
31 three times.
32
33 On the command line or in the ID file, the IDs have the form: TYPE-LET‐
34 TER NUMBER. The type letter is `n' for nodes, `w' for ways, and `r'
35 for relations. If there is no type letter, `n' for nodes is assumed
36 (or whatever the --default-type option says). So “n13 w22 17 r21” will
37 match the nodes 13 and 17, the way 22 and the relation 21.
38
39 The order in which the IDs appear does not matter. Identical IDs can
40 appear multiple times on the command line or in the ID file(s).
41
42 On the command line, the list of IDs can be in separate arguments or in
43 a single argument separated by spaces, tabs, commas (,), semicolons
44 (;), forward slashes (/) or pipe characters (|).
45
46 In an ID file (option --id-file/-i) each line must start with an ID in
47 the format described above. Leading space characters in the line are
48 ignored. Lines can optionally contain a space character or a hash sign
49 (`#') after the ID. Any characters after that are ignored. (This also
50 allows files in OPL format to be read.) Empty lines are ignored.
51
52 Note that all objects will be taken from the OSM-FILE, the ID-OSM-FILE
53 is only used to detect which objects to get. This might matter if
54 there are different object versions in the different files.
55
56 The OSM-FILE can not be a history file unless the --with-history/-H op‐
57 tion is used. Then all versions of the objects will be copied to the
58 output.
59
60 If referenced objects are missing from the input file, the type and IDs
61 of those objects is written out to STDERR at the end of the program un‐
62 less the --with-history/-H option was given.
63
64 This command will not work with negative IDs.
65
67 --default-type=TYPE
68 Use TYPE (`node', `way', or `relation') for IDs without a type
69 prefix (default: `node'). It is also allowed to just use the
70 first character of the type here.
71
72 -H, --with-history
73 Make this program work on history files. This is only needed
74 when using the -r option.
75
76 -i, --id-file[=FILE]
77 Read IDs from text file instead of from the command line. Use
78 the special name “-” to read from STDIN. Each line of the file
79 must start with an ID in the format described above. Lines can
80 optionally contain a space character or a hash sign (`#') after
81 the ID. This character and all following characters are ig‐
82 nored. (This allows files in OPL format to be read.) Empty
83 lines are also ignored. This option can be used multiple times.
84
85 -I, --id-osm-file=OSMFILE
86 Like --id-file/-i but get the IDs from an OSM file. This option
87 can be used multiple times.
88
89 -r, --add-referenced
90 Recursively find all objects referenced by the objects of the
91 given IDs and include them in the output. This only works cor‐
92 rectly on non-history files unless the -H option is also used.
93
94 -t, --remove-tags
95 Remove tags from objects that are not explicitly requested but
96 are only included to complete references (nodes in ways and mem‐
97 bers of relations). If an object is both requested and used as
98 a reference it will keep its tags. You also need --add-refer‐
99 enced/-r for this to make sense.
100
101 --verbose-ids
102 Also print all requested and missing IDs. This is usually dis‐
103 abled, because the lists can get quite long. (This option im‐
104 plies --verbose.)
105
107 -h, --help
108 Show usage help.
109
110 -v, --verbose
111 Set verbose mode. The program will output information about
112 what it is doing to STDERR.
113
114 --progress
115 Show progress bar. Usually a progress bar is only displayed if
116 STDOUT and STDERR are detected to be TTY. With this option a
117 progress bar is always shown. Note that a progress bar will
118 never be shown when reading from STDIN or a pipe.
119
120 --no-progress
121 Do not show progress bar. Usually a progress bar is displayed
122 if STDOUT and STDERR are detected to be a TTY. With this option
123 the progress bar is suppressed. Note that a progress bar will
124 never be shown when reading from STDIN or a pipe.
125
127 -F, --input-format=FORMAT
128 The format of the input file(s). Can be used to set the input
129 format if it can’t be autodetected from the file name(s). This
130 will set the format for all input files, there is no way to set
131 the format for some input files only. See osmium-file-for‐
132 mats(5) or the libosmium manual for details.
133
135 -f, --output-format=FORMAT
136 The format of the output file. Can be used to set the output
137 file format if it can’t be autodetected from the output file
138 name. See osmium-file-formats(5) or the libosmium manual for
139 details.
140
141 --fsync
142 Call fsync after writing the output file to force flushing buf‐
143 fers to disk.
144
145 --generator=NAME
146 The name and version of the program generating the output file.
147 It will be added to the header of the output file. Default is
148 “osmium/” and the version of osmium.
149
150 -o, --output=FILE
151 Name of the output file. Default is `-' (STDOUT).
152
153 -O, --overwrite
154 Allow an existing output file to be overwritten. Normally os‐
155 mium will refuse to write over an existing file.
156
157 --output-header=OPTION=VALUE
158 Add output header option. This command line option can be used
159 multiple times for different OPTIONs. See the osmium-output-
160 headers(5) man page for a list of available header options. For
161 some commands you can use the special format “OPTION!” (ie. an
162 exclamation mark after the OPTION and no value set) to set the
163 value to the same as in the input file.
164
166 osmium getid exits with exit code
167
168 0 if all IDs were found
169
170 1 if there was an error processing the data or not all IDs were
171 found, (this is only detected if the --with-history/-H option
172 was not used),
173
174 2 if there was a problem with the command line arguments.
175
177 osmium getid does all its work on the fly and only keeps a table of all
178 IDs it needs in main memory.
179
181 Output nodes 17 and 1234, way 42, and relation 111 to STDOUT in OPL
182 format:
183
184 osmium getid -f opl planet.osm.pbf n1234 w42 n17 r111
185
187 • osmium(1), osmium-getparents(1), osmium-removeid(1), osmium-file-for‐
188 mats(5), osmium-output-headers(5)
189
190 • Osmium website (https://osmcode.org/osmium-tool/)
191
193 Copyright (C) 2013-2023 Jochen Topf <jochen@topf.org>.
194
195 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/li‐
196 censes/gpl.html>. This is free software: you are free to change and
197 redistribute it. There is NO WARRANTY, to the extent permitted by law.
198
200 If you have any questions or want to report a bug, please go to
201 https://osmcode.org/contact.html
202
204 Jochen Topf <jochen@topf.org>.
205
206
207
208 1.15.0 OSMIUM-GETID(1)