1OSM2PGSQL(1)                                                      OSM2PGSQL(1)
2
3
4

NAME

6       osm2pgsql - Openstreetmap data to PostgreSQL converter
7

SYNOPSIS

9       osm2pgsql [OPTIONS] OSM-FILE...
10

DESCRIPTION

12       osm2pgsql  imports  OpenStreetMap  data into a PostgreSQL/PostGIS data‐
13       base.  It is an essential part of many rendering toolchains, the  Nomi‐
14       natim geocoder and other applications processing OSM data.
15
16       osm2pgsql  can run in either “create” mode (the default) or in “append”
17       mode (option -a, --append).
18
19       In “create” mode osm2pgsql will create the database tables required  by
20       the  configuration  and import the OSM file(s) specified on the command
21       line into those tables.  Note that you also have to use the -s,  --slim
22       option if you want your database to be updateable.
23
24       In  “append”  mode  osm2pgsql  will update the database tables with the
25       data from OSM change files specified on the command line.
26
27       This man page can only cover some of the basics and describe  the  com‐
28       mand      line      options.       See     the     Osm2pgsql     Manual
29       (https://osm2pgsql.org/doc/manual.html) for more information.
30

OPTIONS

32       This program follows the usual GNU command line syntax, with  long  op‐
33       tions  starting  with two dashes (--).  Mandatory arguments to long op‐
34       tions are mandatory for short options too.
35

MAIN OPTIONS

37       -a, --append
38              Run in append mode.  Adds the OSM change file into the  database
39              without removing existing data.
40
41       -c, --create
42              Run  in create mode.  This is the default if -a, --append is not
43              specified.  Removes existing data from the database tables!
44

HELP/VERSION OPTIONS

46       -h, --help
47              Print help.  Add -v, --verbose to display more verbose help.
48
49       -V, --version
50              Print osm2pgsql version.
51

LOGGING OPTIONS

53       --log-level=LEVEL
54              Set log level (`debug', `info' (default), `warn', or `error').
55
56       --log-progress=VALUE
57              Enable (true) or disable (false) progress logging.  Setting this
58              to  auto will enable progress logging on the console and disable
59              it if the output is redirected to a file.  Default: true.
60
61       --log-sql
62              Enable logging of SQL commands for debugging.
63
64       --log-sql-data
65              Enable logging of all data added to  the  database.   This  will
66              write out a huge amount of data! For debugging.
67
68       -v, --verbose
69              Same as --log-level=debug.
70

DATABASE OPTIONS

72       -d, --database=NAME
73              The  name of the PostgreSQL database to connect to.  If this pa‐
74              rameter contains an = sign or starts with  a  valid  URI  prefix
75              (postgresql://  or  postgres://),  it  is  treated as a conninfo
76              string.  See the PostgreSQL manual for details.
77
78       -U, --username=NAME
79              Postgresql user name.
80
81       -W, --password
82              Force password prompt.
83
84       -H, --host=HOSTNAME
85              Database server hostname or unix domain socket location.
86
87       -P, --port=PORT
88              Database server port.
89

INPUT OPTIONS

91       -r, --input-reader=FORMAT
92              Select format of the input file.   Available  choices  are  auto
93              (default)  for  autodetecting the format, xml for OSM XML format
94              files, o5m for o5m formatted files and pbf for  OSM  PBF  binary
95              format.
96
97       -b, --bbox=MINLON,MINLAT,MAXLON,MAXLAT
98              Apply  a  bounding  box  filter  on the imported data.  Example:
99              --bbox -0.5,51.25,0.5,51.75
100

MIDDLE OPTIONS

102       -i, --tablespace-index=TABLESPC
103              Store all indexes in the PostgreSQL tablespace  TABLESPC.   This
104              option also affects the tables created by the pgsql output.
105
106       --tablespace-slim-data=TABLESPC
107              Store the slim mode tables in the given tablespace.
108
109       --tablespace-slim-index=TABLESPC
110              Store  the  indexes  of  the  slim  mode tables in the given ta‐
111              blespace.
112
113       -p, --prefix=PREFIX
114              Prefix for table names (default: planet_osm).
115
116       -s, --slim
117              Store temporary data in the database.  Without  this  mode,  all
118              temporary  data  is  stored in RAM and if you do not have enough
119              the import will not work  successfully.   With  slim  mode,  you
120              should  be able to import the data even on a system with limited
121              RAM, although if you do not have enough RAM to  cache  at  least
122              all  of  the  nodes,  the time to import the data will likely be
123              greatly increased.
124
125       --drop Drop the slim mode tables from the database and  the  flat  node
126              file  once  the import is complete.  This can greatly reduce the
127              size of the database, as the slim mode tables typically are  the
128              same size, if not slightly bigger than the main tables.  It does
129              not, however, reduce the maximum spike of disk usage during  im‐
130              port.   It  can furthermore increase the import speed, as no in‐
131              dexes need to be created for the slim mode  tables,  which  (de‐
132              pending  on  hardware)  can nearly halve import time.  Slim mode
133              tables however have to be persistent if you want to be  able  to
134              update  your  database, as these tables are needed for diff pro‐
135              cessing.
136
137       -C, --cache=NUM
138              Only for slim mode: Use up to NUM MB of RAM for  caching  nodes.
139              Giving  osm2pgsql  sufficient  cache to store all imported nodes
140              typically greatly increases  the  speed  of  the  import.   Each
141              cached  node  requires  8  bytes  of cache, plus about 10% - 30%
142              overhead.  As a rule of thumb, give a bit more than the size  of
143              the  import  file  in PBF format.  If the RAM is not big enough,
144              use about 75% of memory.  Make sure  to  leave  enough  RAM  for
145              PostgreSQL.   It  needs  at  least  the amount of shared_buffers
146              given in its configuration.  Defaults to 800.
147
148       --cache-strategy=STRATEGY
149              This deprecated option will be ignored.
150
151       -x, --extra-attributes
152              Include attributes of each object in the middle tables and  make
153              them  available to the outputs.  Attributes are: user name, user
154              id, changeset id, timestamp and version.
155
156       --flat-nodes=FILENAME
157              The flat-nodes mode is a separate method to store slim mode node
158              information on disk.  Instead of storing this information in the
159              main PostgreSQL database, this mode  creates  its  own  separate
160              custom  database to store the information.  As this custom data‐
161              base has application level knowledge about the data to store and
162              is  not  general  purpose, it can store the data much more effi‐
163              ciently.  Storing the node information for the full  planet  re‐
164              quires more than 300GB in PostgreSQL, the same data is stored in
165              “only” 50GB using the flat-nodes mode.  This can  also  increase
166              the  speed  of  applying  diff files.  This option activates the
167              flat-nodes mode and specifies the location of the database file.
168              It  is  a  single large file.  This mode is only recommended for
169              full planet imports as it doesn't work well with small  imports.
170              The default is disabled.
171
172       --middle-schema=SCHEMA
173              Use  PostgreSQL schema SCHEMA for all tables, indexes, and func‐
174              tions in the middle  (default  is  no  schema,  i.e. the  public
175              schema is used).
176
177       --middle-way-node-index-id-shift=SHIFT
178              Set ID shift for way node bucket index in middle.  Experts only.
179              See documentation for details.
180

OUTPUT OPTIONS

182       -O, --output=OUTPUT
183              Specifies the  output  to  use.   Currently  osm2pgsql  supports
184              pgsql,  flex,  gazetteer  and null.  pgsql is the default output
185              still available for backwards compatibility.  New setups  should
186              use  the  flex output which allows for a much more flexible con‐
187              figuration.  The gazetteer output is intended for geocoding with
188              Nominatim  only.  The null output does not write anything and is
189              only useful for testing or with --slim for creating slim tables.
190
191       -S, --style=FILE
192              The style file.  This specifies how the data  is  imported  into
193              the  database, its format depends on the output.  (For the pgsql
194              output, the default is  /usr/share/osm2pgsql/default.style,  for
195              other outputs there is no default.)
196

PGSQL OUTPUT OPTIONS

198       -i, --tablespace-index=TABLESPC
199              Store  all  indexes in the PostgreSQL tablespace TABLESPC.  This
200              option also affects the middle tables.
201
202       --tablespace-main-data=TABLESPC
203              Store the data tables in the PostgreSQL tablespace TABLESPC.
204
205       --tablespace-main-index=TABLESPC
206              Store the indexes in the PostgreSQL tablespace TABLESPC.
207
208       --latlong
209              Store coordinates in degrees of latitude & longitude.
210
211       -m, --merc
212              Store  coordinates  in   Spherical   Mercator   (Web   Mercator,
213              EPSG:3857) (the default).
214
215       -E, --proj=SRID
216              Use projection EPSG:SRID.
217
218       -p, --prefix=PREFIX
219              Prefix  for  table names (default: planet_osm).  This option af‐
220              fects the middle as well as the pgsql output table names.
221
222       --tag-transform-script=SCRIPT
223              Specify a Lua script to handle tag filtering and  normalisation.
224              The script contains callback functions for nodes, ways and rela‐
225              tions, which each take a set of tags and returns a  transformed,
226              filtered set of tags which are then written to the database.
227
228       -x, --extra-attributes
229              Include  attributes (user name, user id, changeset id, timestamp
230              and version).  This also requires  additional  entries  in  your
231              style file.
232
233       -k, --hstore
234              Add tags without column to an additional hstore (key/value) col‐
235              umn in the database tables.
236
237       -j, --hstore-all
238              Add all tags to an additional hstore (key/value) column  in  the
239              database tables.
240
241       -z, --hstore-column=PREFIX
242              Add  an  additional  hstore (key/value) column named PREFIX con‐
243              taining all tags that  have  a  key  starting  with  PREFIX,  eg
244              \--hstore-column "name:"  will  produce  an  extra hstore column
245              that contains all name:xx tags.
246
247       --hstore-match-only
248              Only keep objects that have a value  in  at  least  one  of  the
249              non-hstore columns.
250
251       --hstore-add-index
252              Create indexes for all hstore columns after import.
253
254       -G, --multi-geometry
255              Normally  osm2pgsql  splits  multi-part geometries into separate
256              database rows per part.  A single OSM object can  therefore  use
257              several  rows in the output tables.  With this option, osm2pgsql
258              instead generates multi-geometry features in the PostgreSQL  ta‐
259              bles.
260
261       -K, --keep-coastlines
262              Keep  coastline  data  rather than filtering it out.  By default
263              objects tagged natural=coastline will be discarded based on  the
264              assumption    that    Shapefiles   generated   by   OSMCoastline
265              (https://osmdata.openstreetmap.de/) will be used for the  coast‐
266              line data.
267
268       --reproject-area
269              Compute area column using spherical mercator coordinates even if
270              a different projection is used for the geometries.
271
272       --output-pgsql-schema=SCHEMA
273              Use PostgreSQL schema SCHEMA for all tables, indexes, and  func‐
274              tions in the pgsql output (default is no schema, i.e. the public
275              schema is used).
276

EXPIRE OPTIONS

278       -e, --expire-tiles=[MIN_ZOOM-]MAX-ZOOM
279              Create a tile expiry list.
280
281       -o, --expire-output=FILENAME
282              Output file name for expired tiles list.
283
284       --expire-bbox-size=SIZE
285              Max size for a polygon to expire the whole polygon, not just the
286              boundary.
287

ADVANCED OPTIONS

289       -I, --disable-parallel-indexing
290              Disable  parallel  clustering  and index building on all tables,
291              build one index after the other.
292
293       --number-processes=THREADS
294              Specifies the number of parallel threads used for certain opera‐
295              tions.
296
297       --with-forward-dependencies=BOOL
298              Propagate changes from nodes to ways and node/way members to re‐
299              lations (Default: true).
300

SEE ALSO

302       • osm2pgsql website (https://osm2pgsql.org)
303
304       • osm2pgsql manual (https://osm2pgsql.org/doc/manual.html)
305
306postgres(1)
307
308       • osmcoastline(1)
309
310
311
312                                     1.5.1                        OSM2PGSQL(1)
Impressum