OSMIUM-SORT(1)
β¨ OSMIUM-SORT β¨
okay so bestie, say hi to osmium-sort, the part of the osmium family that sorts OSM files. this is the osmium-sort(1) manual, and yes we're reading it together, no skimming π
π NAME π
osmium-sort β sort OSM files. that's it. that's the whole job. and it does it flawlessly obviously.
π¦ SYNOPSIS π¦
osmium sort [OPTIONS] OSM-FILE...
πΈ DESCRIPTION πΈ
so what it does: it combines and sorts the content of <em>all</em> the input files you hand it on the command line. all of them. together. as one. slay π«Ά
Objects get sorted by type, then ID, then version. and here's the lil twist that trips people up β IDs are sorted negative IDs first, then positive IDs, and <em>both</em> of those groups are ordered by their absolute values. so yeah, -1 comes before -2, bestie. it's giving "math class but make it fashion".
so the sort order for types and IDs goes like this:
node -1, node -2, ..., node 1, node 2, ..., way -1, way -2, ..., way 1, way 2, ..., relation -1, relation -2, ..., relation 1, relation 2, ...
if there are several objects of the same type and the same ID, they get ordered by ascending version. β¨
and if there are several objects of the same type, same ID, <em>and</em> same version? the sort order is unspecified. it's giving chaos, honestly. also, heads up: duplicate objects will not be removed. no deduping, no cleaning up after you, it just sorts. periodt.
this command works with normal OSM data files, history files, and change files. versatile queen π
and the streaming situation β this command reads its input file(s) only once and writes its output file in one go, so it can be streamed, ie. it can read from STDIN and write to STDOUT. (unless the multipass strategy is used, but more on that in a sec π)
π OPTIONS π
-s,--strategy=STRATEGYβ the sorting strategy, aka how we're doing this. thesimplestrategy reads all input files into memory, does the sorting, and writes everything out. themultipassstrategy reads the input files in three passes β one for nodes, one for ways, and one for relations. after reading all objects of each type, they get sorted and written out. it's a bit slower thansimple, but it uses less memory. heads up tho:multipassdoesn't work when reading fromSTDIN. default:simple.
π COMMON OPTIONS π
-h,--helpβ show usage help. your lil map when you're lost πΊοΈ-v,--verboseβ set verbose mode. the program will output information about what it is doing toSTDERR. it's basically narrating its own life π¬--progressβ show progress bar. usually a progress bar is only displayed ifSTDOUTandSTDERRare detected to be a 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). use it to set the input format if it can't be autodetected from the file name(s). this sets 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. use it 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. making sure it's really really there πΎ--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/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. protective king π‘οΈ--output-header=OPTION=VALUEβ add output header option. this command line option can be used multiple times for differentOPTIONs. see theosmium-output-headers(5)man page for a list of available header options. for some commands you can use the special formatOPTION!(ie. an exclamation mark after theOPTIONand no value set) to set the value to the same as in the input file.
π DIAGNOSTICS π
osmium sort exits with exit code
0β if everything went alright π1β if there was an error processing the data π2β if there was a problem with the command line arguments π
π§ MEMORY USAGE π§
osmium sort keeps the contents of all the input files in main memory. and babes, this will take roughly 10 times as much memory as the files take on disk in .osm.bz2 or osm.pbf format. plan accordingly, your RAM is not infinite bestie π
β EXAMPLES β
sort in.osm.bz2 and write out to sorted.osm.pbf:
osmium sort -o sorted.osm.pbf in.osm.bz2
iconic. ate. no notes.
π₯ SEE ALSO π₯
osmium(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 π this was version 1.19.1 of the osmium-sort(1) manual β go sort something iconic, ily, bye πβ¨
π¦ 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