1OSM2PGSQL(1) OSM2PGSQL(1)
2
3
4
6 osm2pgsql - OpenStreetMap data to PostgreSQL converter
7
9 osm2pgsql [OPTIONS] OSM-FILE...
10
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 updatable.
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
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
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
46 -h, --help
47 Print help. Add -v, --verbose to display more verbose help.
48
49 -V, --version
50 Print osm2pgsql version.
51
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
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
90 --schema=SCHEMA
91 Default for various schema settings throughout osm2pgsql (de‐
92 fault: public). The schema must exist in the database and be
93 writable by the database user.
94
96 -r, --input-reader=FORMAT
97 Select format of the input file. Available choices are auto
98 (default) for autodetecting the format, xml for OSM XML format
99 files, o5m for o5m formatted files and pbf for OSM PBF binary
100 format.
101
102 -b, --bbox=MINLON,MINLAT,MAXLON,MAXLAT
103 Apply a bounding box filter on the imported data. Example:
104 --bbox -0.5,51.25,0.5,51.75
105
107 -i, --tablespace-index=TABLESPC
108 Store all indexes in the PostgreSQL tablespace TABLESPC. This
109 option also affects the tables created by the pgsql output.
110
111 --tablespace-slim-data=TABLESPC
112 Store the slim mode tables in the given tablespace.
113
114 --tablespace-slim-index=TABLESPC
115 Store the indexes of the slim mode tables in the given ta‐
116 blespace.
117
118 -p, --prefix=PREFIX
119 Prefix for table names (default: planet_osm).
120
121 -s, --slim
122 Store temporary data in the database. Without this mode, all
123 temporary data is stored in RAM and if you do not have enough
124 the import will not work successfully. With slim mode, you
125 should be able to import the data even on a system with limited
126 RAM, although if you do not have enough RAM to cache at least
127 all of the nodes, the time to import the data will likely be
128 greatly increased.
129
130 --drop Drop the slim mode tables from the database and the flat node
131 file once the import is complete. This can greatly reduce the
132 size of the database, as the slim mode tables typically are the
133 same size, if not slightly bigger than the main tables. It does
134 not, however, reduce the maximum spike of disk usage during im‐
135 port. It can furthermore increase the import speed, as no in‐
136 dexes need to be created for the slim mode tables, which (de‐
137 pending on hardware) can nearly halve import time. Slim mode
138 tables however have to be persistent if you want to be able to
139 update your database, as these tables are needed for diff pro‐
140 cessing.
141
142 -C, --cache=NUM
143 Only for slim mode: Use up to NUM MB of RAM for caching nodes.
144 Giving osm2pgsql sufficient cache to store all imported nodes
145 typically greatly increases the speed of the import. Each
146 cached node requires 8 bytes of cache, plus about 10% - 30%
147 overhead. As a rule of thumb, give a bit more than the size of
148 the import file in PBF format. If the RAM is not big enough,
149 use about 75% of memory. Make sure to leave enough RAM for
150 PostgreSQL. It needs at least the amount of shared_buffers
151 given in its configuration. Defaults to 800.
152
153 --cache-strategy=STRATEGY
154 This deprecated option will be ignored.
155
156 -x, --extra-attributes
157 Include attributes of each object in the middle tables and make
158 them available to the outputs. Attributes are: user name, user
159 id, changeset id, timestamp and version.
160
161 --flat-nodes=FILENAME
162 The flat-nodes mode is a separate method to store slim mode node
163 information on disk. Instead of storing this information in the
164 main PostgreSQL database, this mode creates its own separate
165 custom database to store the information. As this custom data‐
166 base has application level knowledge about the data to store and
167 is not general purpose, it can store the data much more effi‐
168 ciently. Storing the node information for the full planet re‐
169 quires more than 300GB in PostgreSQL, the same data is stored in
170 “only” 50GB using the flat-nodes mode. This can also increase
171 the speed of applying diff files. This option activates the
172 flat-nodes mode and specifies the location of the database file.
173 It is a single large file. This mode is only recommended for
174 full planet imports as it doesn’t work well with small imports.
175 The default is disabled.
176
177 --middle-schema=SCHEMA
178 Use PostgreSQL schema SCHEMA for all tables, indexes, and func‐
179 tions in the middle. The schema must exist in the database and
180 be writable by the database user. By default the schema set
181 with --schema is used, or public if that is not set.
182
183 --middle-way-node-index-id-shift=SHIFT
184 Set ID shift for way node bucket index in middle. Experts only.
185 See documentation for details.
186
187 --middle-database-format=FORMAT
188 Set the database format for the middle tables to FORMAT. Al‐
189 lowed formats are legacy and new. The legacy format is the old
190 format that will eventually be deprecated and removed but is
191 currently still the default. The new format was introduced in
192 version 1.9.0 and is still experimental. See the manual for de‐
193 tails on these formats. (Only works with --slim. In append
194 mode osm2pgsql will automatically detect the database format, so
195 don’t use this with -a, --append.)
196
197 --middle-with-nodes
198 Used together with the new middle database format when a flat
199 nodes file is used to force storing nodes with tags in the data‐
200 base, too.
201
203 -O, --output=OUTPUT
204 Specifies the output to use. Currently osm2pgsql supports
205 pgsql, flex, gazetteer and null. pgsql is the default output
206 still available for backwards compatibility. New setups should
207 use the flex output which allows for a much more flexible con‐
208 figuration. The gazetteer output is intended for geocoding with
209 Nominatim only. The null output does not write anything and is
210 only useful for testing or with --slim for creating slim tables.
211
212 -S, --style=FILE
213 The style file. This specifies how the data is imported into
214 the database, its format depends on the output. (For the pgsql
215 output, the default is /usr/share/osm2pgsql/default.style, for
216 other outputs there is no default.)
217
219 -i, --tablespace-index=TABLESPC
220 Store all indexes in the PostgreSQL tablespace TABLESPC. This
221 option also affects the middle tables.
222
223 --tablespace-main-data=TABLESPC
224 Store the data tables in the PostgreSQL tablespace TABLESPC.
225
226 --tablespace-main-index=TABLESPC
227 Store the indexes in the PostgreSQL tablespace TABLESPC.
228
229 --latlong
230 Store coordinates in degrees of latitude & longitude.
231
232 -m, --merc
233 Store coordinates in Spherical Mercator (Web Mercator,
234 EPSG:3857) (the default).
235
236 -E, --proj=SRID
237 Use projection EPSG:SRID.
238
239 -p, --prefix=PREFIX
240 Prefix for table names (default: planet_osm). This option af‐
241 fects the middle as well as the pgsql output table names.
242
243 --tag-transform-script=SCRIPT
244 Specify a Lua script to handle tag filtering and normalisation.
245 The script contains callback functions for nodes, ways and rela‐
246 tions, which each take a set of tags and returns a transformed,
247 filtered set of tags which are then written to the database.
248
249 -x, --extra-attributes
250 Include attributes (user name, user id, changeset id, timestamp
251 and version). This also requires additional entries in your
252 style file.
253
254 -k, --hstore
255 Add tags without column to an additional hstore (key/value) col‐
256 umn in the database tables.
257
258 -j, --hstore-all
259 Add all tags to an additional hstore (key/value) column in the
260 database tables.
261
262 -z, --hstore-column=PREFIX
263 Add an additional hstore (key/value) column named PREFIX con‐
264 taining all tags that have a key starting with PREFIX, eg
265 \--hstore-column "name:" will produce an extra hstore column
266 that contains all name:xx tags.
267
268 --hstore-match-only
269 Only keep objects that have a value in at least one of the non-
270 hstore columns.
271
272 --hstore-add-index
273 Create indexes for all hstore columns after import.
274
275 -G, --multi-geometry
276 Normally osm2pgsql splits multi-part geometries into separate
277 database rows per part. A single OSM object can therefore use
278 several rows in the output tables. With this option, osm2pgsql
279 instead generates multi-geometry features in the PostgreSQL ta‐
280 bles.
281
282 -K, --keep-coastlines
283 Keep coastline data rather than filtering it out. By default
284 objects tagged natural=coastline will be discarded based on the
285 assumption that Shapefiles generated by OSMCoastline
286 (https://osmdata.openstreetmap.de/) will be used for the coast‐
287 line data.
288
289 --reproject-area
290 Compute area column using spherical mercator coordinates even if
291 a different projection is used for the geometries.
292
293 --output-pgsql-schema=SCHEMA
294 Use PostgreSQL schema SCHEMA for all tables, indexes, and func‐
295 tions in the pgsql output. The schema must exist in the data‐
296 base and be writable by the database user. By default the
297 schema set with --schema is used, or public if that is not set.
298
300 -e, --expire-tiles=[MIN_ZOOM-]MAX-ZOOM
301 Create a tile expiry list.
302
303 -o, --expire-output=FILENAME
304 Output file name for expired tiles list.
305
306 --expire-bbox-size=SIZE
307 Max size for a polygon to expire the whole polygon, not just the
308 boundary.
309
311 -I, --disable-parallel-indexing
312 Disable parallel clustering and index building on all tables,
313 build one index after the other.
314
315 --number-processes=THREADS
316 Specifies the number of parallel threads used for certain opera‐
317 tions.
318
319 --with-forward-dependencies=BOOL
320 Propagate changes from nodes to ways and node/way members to re‐
321 lations (Default: true).
322
324 • osm2pgsql website (https://osm2pgsql.org)
325
326 • osm2pgsql manual (https://osm2pgsql.org/doc/manual.html)
327
328 • postgres(1)
329
330 • osmcoastline(1)
331
332
333
334 1.9.2 OSM2PGSQL(1)