1OSMCONVERT(1)               General Commands Manual              OSMCONVERT(1)
2
3
4

NAME

6       osmconvert - Converter of OSM files
7

SYNOPSIS

9       osmconvert options [input file]
10

DESCRIPTION

12       This  program reads different file formats of the OpenStreetMap project
13       and converts the data to the selected output file format.
14
15   These formats can be read:
16       .osm .osc .osc.gz .osh .o5m .o5c .pbf
17
18   These formats can be written:
19       .osm (default) .osc .osh .o5m .o5c .pbf
20
21       Names of input files must be specified as command line parameters.  Use
22       -  to  read  from  standard input. You do not need to specify the input
23       formats, osmconvert will recognize them by itself.  The  output  format
24       is  .osm  by default. If you want a different format, please specify it
25       using the appropriate command line parameter.
26

OPTIONS

28       -b=<x1>,<y1>,<x2>,<y2>
29
30              If you want to limit the geographical region, you can  define  a
31              bounding  box. To do this, enter the southwestern and the north‐
32              eastern corners of that area. For example: -b=-0.5,51,0.5,52
33
34       -B=<border_polygon>
35
36              Alternatively to a bounding box you can use a border polygon  to
37              limit  the  geographical region.  The format of a border polygon
38              file  can  be  found  in  the   OSM   Wiki:   https://wiki.open
39              streetmap.org/wiki/Osmosis/Polygon_Filter_File_Format
40              You  do  not need to strictly follow the format description, you
41              must ensure that every line of coordinates starts with blanks.
42
43       --complete-ways
44
45              If applying a border box or a border polygon, all nodes the bor‐
46              ders  are  excluded;  even then if they belong to a way which is
47              not entirely excluded because it has some nodes inside the  bor‐
48              ders.   This  option  will ensure that every way stays complete,
49              even it it intersects the borders. This will  result  in  slower
50              processing,  and the program will loose its ability to read from
51              standard input. It is recommended to use .o5m  format  as  input
52              format to compensate most of the speed disadvantage.
53
54       --complex-multipolygons, --complex-boundaries
55
56              Same  as  before, but multipolygons resp. boundaries will not be
57              cut at the borders too.
58
59       --all-to-nodes
60
61              Some applications do not have the ability  to  process  ways  or
62              relations,  they  just  accept nodes as input. However, more and
63              more complex object are mapped as  ways  or  even  relations  in
64              order  to  get  all their details into the database.  Apply this
65              option if you want to convert ways and relations  to  nodes  and
66              thereby  make them available to applications which can only deal
67              with nodes.  For each way a node is created.  The  way's  id  is
68              increased  by 10^15 and taken as id for the new node. The node's
69              longitude and latitude are set to the way's geographical center.
70              Same  applies  to relations, however they get 2*10^15 as id off‐
71              set.
72
73       --add-bbox-tags
74
75              This option adds a tag with a bounding box to each object.   The
76              tag  will contain the border coordinates in this order: min Lon‐
77              gitude, min Latitude, max Longitude , max Latitude.  e.g.:  <tag
78              k="bBox" v="-0.5000,51.0000,0.5000,52.0000"/>
79
80       --add-bboxarea-tags
81
82              A  tag for an estimated area value for the bbox is added to each
83              way and each relation. The unit is square meters.  For  example:
84              <tag k="bBoxArea" v="33828002"/>
85
86       --add-bboxweight-tags
87
88              This  option  will  add the binary logarithm of the bbox area of
89              each way and each relation.  For example:   <tag  k="bBoxWeight"
90              v="20"/>
91
92       --add-bboxwidth-tags
93
94              A tag for an estimated width value for the bbox is added to each
95              way and each relation. The unit is meters.  For  example:   <tag
96              k="bBoxWidth" v="825"/>
97
98       --add-bboxwidthweight-tags
99
100              This  option  will add the binary logarithm of the bbox width of
101              each way and each relation.  For  example:   <tag  k="bBoxWidth‐
102              Weight" v="10"/>
103
104       --object-type-offset=<id offset>
105
106              If  applying  the  --all-to-nodes option as explained above, you
107              may  adjust  the  id  offset.  For  example:  --object-type-off‐
108              set=4000000000
109              By  appending "+1" to the offset, the program will create ids in
110              a sequence with step 1. This might be useful if the there  is  a
111              subsequently  running  application which cannot process large id
112              numbers. Example:
113              --object-type-offset=1900000000+1
114
115       --drop-broken-refs
116
117              Use this option if you need to delete references to nodes  which
118              have  been excluded because lying outside the borders (mandatory
119              for some applications, e.g. Map Composer, JOSM).
120
121       --drop-author
122
123              For most applications the author tags are  not  needed.  If  you
124              specify  this  option, no author information will be written: no
125              changeset, user or timestamp.
126
127       --drop-version
128
129              If you want to exclude not only the author information but  also
130              the version number, specify this option.
131
132       --drop-nodes --drop-ways --drop-relations
133
134              According  to the combination of these parameters, no members of
135              the referred section will be written.
136
137       --modify-tags=<tag_modification_list>
138
139              The tag modification list determines which tags  will  be  modi‐
140              fied.  The example --modify-tags="highway=primary to =secondary"
141              will change every "primary" highway into "secondary".   You  can
142              also  use  comparisons  or  add  additional  tags: --modify-way-
143              tags="maxspeed>200 add highspeed=yes"
144
145       --modify-node-tags=TAG_MODIFICATION_LIST  --modify-way-tags=TAG_MODIFI‐
146       CATION_LIST     --modify-relation-tags=TAG_MODIFICATION_LIST     --mod‐
147       ify-node-way-tags=TAG_MODIFICATION_LIST             --modify-node-rela‐
148       tion-tags=TAG_MODIFICATION_LIST  --modify-way-relation-tags=TAG_MODIFI‐
149       CATION_LIST
150
151              Same as above, but just for the specified object types.
152
153       --diff
154
155              Calculate difference between two files and create a new .osc  or
156              .o5c  file.  There must be TWO input files and borders cannot be
157              applied.  Both files must be sorted by object type and id.  Cre‐
158              ated  objects  will  appear  in  the  output file as "modified",
159              unless having version number 1.
160
161       --diff-contents
162
163              Similar to --diff, this option  calculates  differences  between
164              two  OSM  files. Here, to determine the differences complete OSM
165              objects are consulted, not only the version  numbers.   Unfortu‐
166              nately,  this  option strictly requires both input files to have
167              .o5m format.
168
169       --subtract
170
171              The output file will not contain any object which exists in  one
172              of  the  input files following this directive. For example: osm‐
173              convert input.o5m --subtract minus.o5m -o=output.o5m
174
175       --pbf-granularity=<val>
176
177              Rarely .pbf files come with non-standard  granularity.   osmcon‐
178              vert  will  recognize  this  and suggest to specify the abnormal
179              lon/lat granularity using this  command  line  option.   Allowed
180              values are: 100 (default), 1000, 10000, ..., 10000000.
181
182       --emulate-osmosis --emulate-pbf2osm
183
184              In  case  of .osm output format, the program will try to use the
185              same data syntax as Osmosis, resp. pbf2osm.
186
187       --fake-author
188
189              If you have dropped author information (--drop-author) that data
190              will  be  lost,  of course. Some programs however require author
191              information on input although they do not need  that  data.  For
192              this  purpose,  you can fake the author information.  osmconvert
193              will write changeset 1, timestamp 1970.
194
195       --fake-version
196
197              Same as --fake-author, but - if .osm xml is used as output  for‐
198              mat - only the version number will be written (version 1).  This
199              is useful if you want to inspect the data with JOSM.
200
201       --fake-lonlat
202
203              Some programs depend on getting longitude/latitude values,  even
204              when  the  object in question shall be deleted. With this option
205              you can have osmconvert to fake these values:
206              ... lat="0" lon="0" ...
207              Note that this is for XML files only (.osc and .osh).
208
209       -h
210
211              Display a short parameter overview.
212
213       --help
214
215              Display this help.
216
217       --merge-versions
218
219              Some .osc files contain different versions of one  object.   Use
220              this option to accept such duplicates on input.
221
222       --out-osm
223
224              Data  will be written in .osm format. This is the default output
225              format.
226
227       --out-osc
228
229              The OSM Change format will be used for output. Please note  that
230              OSM objects which are to be deleted will be represented by their
231              ids only.
232
233       --out-osh
234
235              For every OSM object, the  appropriate  'visible'  tag  will  be
236              added to meet 'full planet history' specification.
237
238       --out-o5m
239
240              The .o5m format will be used. This format has the same structure
241              as the conventional .osm format, but  the  data  are  stored  as
242              binary  numbers and are therefore much more compact than in .osm
243              format. No packing is used, so you can  pack  .o5m  files  using
244              every file packer you want, e.g. lzo, bz2, etc.
245
246       --out-o5c
247
248              This is the change file format of .o5m data format. All <delete>
249              tags will not be performed as delete actions but converted  into
250              .o5c data format.
251
252       --out-pbf
253
254              For output, PBF format will be used.
255
256       --out-csv
257
258              A  character  separated  list  will  be  written to output.  The
259              default separator is Tab, the default  columns  are:  type,  id,
260              name.  You can change both by using the options --csv-separator=
261              and --csv=
262
263       --csv-headline
264
265              Choose this option to print a headline to csv output.
266
267       --csv-separator=<sep>
268
269              You may change the default separator (Tab) to a different  char‐
270              acter or character sequence. For example: --csv-separator="; "
271
272       --csv=<columns>
273
274              If  you  want  to  have certain columns in your csv list, please
275              specify their names as shown in this  example:  --csv="@id  name
276              ref description" There are a few special column names for header
277              data: @otype (object type 0..2), @oname (object type name),  @id
278              @lon, @lat, @version, @timestamp, @changeset, @uid, @user
279
280       --out-none
281
282              This will be no standard output. This option is for testing pur‐
283              poses only.
284
285       --timestamp=<date_and_time> --timestamp=NOW<seconds_relative_to_now>
286
287              If you want to set the OSM timestamp of your output file, supply
288              it  with  this option. Date and time must be formatted according
289              OSM   date/time    specifications.    For    example:    --time‐
290              stamp=2011-01-31T23:59:30Z  You  also can supply a relative time
291              in seconds, e.g. 24h ago: --timestamp=NOW-86400
292
293       --out-timestamp
294
295              With this option set, osmconvert prints just the time  stamp  of
296              the input file, nothing else.
297
298       --statistics
299
300              This  option  activates  a  statistics counter. The program will
301              print statistical data to stderr.
302
303       --out-statistics
304
305              Same as --statistics, but the statistical data will  be  written
306              to standard output.
307
308       -o=<outfile>
309
310              Standard  output  will be rerouted to the specified file.  If no
311              output format has been specified, the program will rely  on  the
312              file name extension.
313
314       -t=<tempfile>
315
316              If  borders  are to be applied or broken references to be elimi‐
317              nated, osmconvert creates and uses two  temporary  files.   This
318              parameter  defines their name prefix. The default value is "osm‐
319              convert_tempfile".
320
321       --parameter-file=FILE
322
323              If you want to supply one ore more command line arguments  by  a
324              parameter  file,  please  use  this  option and specify the file
325              name. Within the parameter file, parameters must be separated by
326              empty  lines. Line feeds inside a parameter will be converted to
327              spaces.  Lines starting with "// " will be treated as comments.
328
329       -v --verbose
330
331              With activated 'verbose' mode, some statistical data and diagno‐
332              sis  data will be displayed.  If -v resp. --verbose is the first
333              parameter in the line, osmconvert will display all input parame‐
334              ters.
335

TUNING

337       To  speed-up  the process, the program uses some main memory for a hash
338       table. By default, it uses 1200 MB for storing a flag for every  possi‐
339       ble  node,  150  for  the way flags, and 10 relation flags.  Every byte
340       holds the flags for 8 ID numbers, i.e., in  1200  MB  the  program  can
341       store  9600  million flags. As there are less than 5700 million IDs for
342       nodes at present (May 2018), 720 MB would suffice.   So,  for  example,
343       you  can  decrease  the  hash sizes to e.g. 720, 80 and 2 MB using this
344       option:
345
346       --hash-memory=720-80-2
347
348       But keep in mind that the OSM database is continuously  expanding.  For
349       this  reason  the program-own default value is higher than shown in the
350       example, and it may be appropriate to increase it in  the  future.   If
351       you do not want to bother with the details, you can enter the amount of
352       memory as a sum, and the program will divide it by itself.   For  exam‐
353       ple:
354
355       --hash-memory=1000
356
357       These  1000  MiB  will  be split in three parts: 800 for nodes, 150 for
358       ways, and 50 for relations.
359
360       Because we are taking hashes, it is not necessary to  provide  all  the
361       suggested  memory;  the program will operate with less hash memory too.
362       But, in this case, the border filter will be less effective, i.e., some
363       ways  and  some relations will be left in the output file although they
364       should have been excluded.  The maximum value the program  accepts  for
365       the  hash  size is 4000 MiB; If you exceed the maximum amount of memory
366       available on your system, the program will try to  reduce  this  amount
367       and display a warning message.
368
369       There is another temporary memory space which is used only for the con‐
370       version of ways and relations to nodes (option  --all-to-nodes).   This
371       space  is sufficient for up to 25 Mio. OSM objects, 400 MB of main mem‐
372       ory  are  needed  for  this  purpose,  800  MB   if   extended   option
373       --add-bbox-tags  has  been invoked. If this is not sufficient or if you
374       want to save memory, you  can  configure  the  maximum  number  of  OSM
375       objects by yourself. For example:
376
377       --max-objects=35000000
378
379       The number of references per object is limited to 100,000. This will be
380       sufficient for all OSM files. If you are going to create your  own  OSM
381       files by converting shapefiles or other files to OSM format, this might
382       result in way objects with more than 100,000 nodes. For this reason you
383       will need to increase the maximum accordingly. Example:
384
385       --max-refs=400000
386

LIMITATIONS

388       When  extracting a geographical region (using -b or -B), the input file
389       must contain the objects ordered by their type: first, all nodes, next,
390       all ways, followed by all relations. Within each of these sections, the
391       objects section must be sorted by their id in ascending order.
392
393       Usual .osm, .osc, .o5m, o5c and .pbf files adhere  to  this  condition.
394       This  means  that you do not have to worry about this limitation.  osm‐
395       convert will display an error message if this sequence is broken.
396
397       If a polygon file for borders is supplied, the maximum number of  poly‐
398       gon points is about 40,000.
399

NOTES

401       This  program  is  for  experimental  use. Expect malfunctions and data
402       loss. Do not use the program in productive or commercial systems.
403
404       There is NO WARRANTY, to the extent permitted by law.  Please send  any
405       bug reports to marqqs@gmx.eu
406

EXAMPLE

408       osmconvert europe.pbf --drop-author >europe.osm
409       osmconvert europe.pbf |gzip >europe.osm.gz
410       bzcat europe.osm.bz2 |./osmconvert --out-pbf >europe.pbf
411       osmconvert europe.pbf -B=ch.poly >switzerland.osm
412       osmconvert switzerland.osm --out-o5m >switzerland.o5m
413       osmconvert june_july.osc --out-o5c >june_july.o5c
414       osmconvert june.o5m june_july.o5c.gz --out-o5m >july.o5m
415       osmconvert sep.osm sep_oct.osc oct_nov.osc >nov.osm
416       osmconvert northamerica.osm southamerica.osm >americas.osm
417

SEE ALSO

419       osmfilter(1), osmupdate(1)
420

AUTHORS

422       osmconvert was written by Markus Weber
423
424
425
426
427                                September 2013                   OSMCONVERT(1)
Impressum