1OSM2PGSQL(1) General Commands Manual OSM2PGSQL(1)
2
3
4
6 osm2pgsql - Openstreetmap data to PostgreSQL converter.
7
9 osm2pgsql [options] planet.osm
10 osm2pgsql [options] planet.osm.{gz,bz2,pbf}
11 osm2pgsql [options] file1.osm file2.osm file3.osm
12
14 This manual page documents briefly the osm2pgsql command.
15
16 osm2pgsql imports data from OSM file(s) into a PostgreSQL database
17 suitable for use by the Mapnik renderer or the Nominatim geocoder.
18 OSM planet snapshots can be downloaded from https://planet.open‐
19 streetmap.org/. Partial planet files ("extracts") for various countries
20 are available, see https://wiki.openstreetmap.org/wiki/Planet.osm.
21
22 Extracts in PBF (ProtoBufBinary) format are also available from
23 https://download.geofabrik.de/.
24
25 When operating in "slim" mode (and on a database created in "slim"
26 mode!), osm2pgsql can also process OSM change files (osc files),
27 thereby bringing an existing database up to date.
28
30 This program follows the usual GNU command line syntax, with long
31 options starting with two dashes (`-'). A summary of options is
32 included below.
33
34 -a|--append
35 Add the OSM file into the database without removing existing
36 data.
37
38 -b|--bbox
39 Apply a bounding box filter on the imported data. Must be spec‐
40 ified as: minlon,minlat,maxlon,maxlat e.g. --bbox
41 -0.5,51.25,0.5,51.75
42
43 -c|--create
44 Remove existing data from the database. This is the default if
45 --append is not specified.
46
47 -d|--database name
48 The name of the PostgreSQL database to connect to.
49
50 -i|--tablespace-index tablespacename
51 Store all indices in a separate PostgreSQL tablespace named by
52 this parameter. This allows one to e.g. store the indices on
53 faster storage like SSDs.
54
55 --tablespace-main-data tablespacename
56 Store the data tables (non slim) in the given tablespace.
57
58 --tablespace-main-index tablespacename
59 Store the indices of the main tables (non slim) in the given
60 tablespace.
61
62 --tablespace-slim-data tablespacename
63 Store the slim mode tables in the given tablespace.
64
65 --tablespace-slim-index tablespacename
66 Store the indices of the slim mode tables in the given
67 tablespace.
68
69 -l|--latlong
70 Store data in degrees of latitude & longitude.
71
72 -m|--merc
73 Store data in Spherical Mercator (Web Mercator, EPSG:3857) (the
74 default).
75
76 -E|--proj num
77 Use projection EPSG:num.
78
79 -p|--prefix prefix_string
80 Prefix for table names (default: planet_osm).
81
82 -r|--input-reader format
83 Select format of the input file. Available choices are auto
84 (default) for autodetecting the format, xml for OSM XML format
85 files, o5m for o5m formatted files and pbf for OSM PBF binary
86 format.
87
88 -s|--slim
89 Store temporary data in the database. Without this mode, all
90 temporary data is stored in RAM and if you do not have enough
91 the import will not work successfully. With slim mode, you
92 should be able to import the data even on a system with limited
93 RAM, although if you do not have enough RAM to cache at least
94 all of the nodes, the time to import the data will likely be
95 greatly increased.
96
97 --drop
98 Drop the slim mode tables from the database once the import is
99 complete. This can greatly reduce the size of the database, as
100 the slim mode tables typically are the same size, if not
101 slightly bigger than the main tables. It does not, however,
102 reduce the maximum spike of disk usage during import. It can
103 furthermore increase the import speed, as no indices need to be
104 created for the slim mode tables, which (depending on hardware)
105 can nearly halve import time. Slim mode tables however have to
106 be persistent if you want to be able to update your database, as
107 these tables are needed for diff processing.
108
109 -S|--style /path/to/style
110 Location of the osm2pgsql style file. This specifies which tags
111 from the data get imported into database columns and which tags
112 get dropped. Defaults to /usr/share/osm2pgsql/default.style.
113
114 -C|--cache num
115 Only for slim mode: Use up to num many MB of RAM for caching
116 nodes. Giving osm2pgsql sufficient cache to store all imported
117 nodes typically greatly increases the speed of the import. Each
118 cached node requires 8 bytes of cache, plus about 10% - 30%
119 overhead. As a rule of thumb, give a bit more than the size of
120 the import file in PBF format. If the RAM is not big enough, use
121 about 75% of memory. Make sure to leave enough RAM for Post‐
122 greSQL. It needs at least the amount of `shared_buffers` given
123 in its configuration. Defaults to 800.
124
125 --cache-strategy strategy
126 There are a number of different modes in which osm2pgsql can
127 organize its node cache in RAM. These are optimized for differ‐
128 ent assumptions of the data and the hardware resources avail‐
129 able. Currently available strategies are dense, chunked, sparse
130 and optimized. dense assumes that the node id numbers are
131 densely packed, i.e. only a few IDs in the range are missing /
132 deleted. For planet extracts this is usually not the case, mak‐
133 ing the cache very inefficient and wasteful of RAM. sparse
134 assumes node IDs in the data are not densely packed, greatly
135 increasing caching efficiency in these cases. If node IDs are
136 densely packed, like in the full planet, this strategy has a
137 higher overhead for indexing the cache. optimized uses both
138 dense and sparse strategies for different ranges of the ID
139 space. On a block by block basis it tries to determine if it is
140 more effective to store the block of IDs in sparse or dense
141 mode. This is the default and should be typically used.
142
143 -U|--username name
144 Postgresql user name.
145
146 -W|--password
147 Force password prompt.
148
149 -H|--host hostname
150 Database server hostname or socket location.
151
152 -P|--port num
153 Database server port.
154
155 -e|--expire-tiles [min_zoom-]max-zoom
156 Create a tile expiry list.
157
158 -o|--expire-output /path/to/expire.list
159 Output file name for expired tiles list.
160
161 -O|--output
162 Specifies the output back-end or database schema to use. Cur‐
163 rently osm2pgsql supports pgsql, flex, gazetteer and null. pgsql
164 is the default output back-end / schema and is optimized for
165 rendering with Mapnik. gazetteer is a db schema optimized for
166 geocoding and is used by Nominatim. The experimental flex back‐
167 end allows more flexible configuration. null does not write any
168 output and is only useful for testing or with --slim for creat‐
169 ing slim tables. There is also a multi backend. This is now dep‐
170 recated and will be removed in future versions of osm2pgsql.
171
172 -x|--extra-attributes
173 Include attributes for each object in the database. This
174 includes the username, userid, timestamp and version. Note:
175 this option also requires additional entries in your style file.
176
177 -k|--hstore
178 Add tags without column to an additional hstore (key/value) col‐
179 umn to PostgreSQL tables.
180
181 -j|--hstore-all
182 Add all tags to an additional hstore (key/value) column in Post‐
183 greSQL tables.
184
185 -z|--hstore-column key_name
186 Add an additional hstore (key/value) column containing all tags
187 that start with the specified string, eg --hstore-column "name:"
188 will produce an extra hstore column that contains all name:xx
189 tags
190
191 --hstore-match-only
192 Only keep objects that have a value in one of the columns (nor‐
193 mal action with --hstore is to keep all objects).
194
195 --hstore-add-index
196 Create indices for the hstore columns during import.
197
198 -G|--multi-geometry
199 Normally osm2pgsql splits multi-part geometries into separate
200 database rows per part. A single OSM id can therefore have sev‐
201 eral rows. With this option, PostgreSQL instead generates
202 multi-geometry features in the PostgreSQL tables.
203
204 -K|--keep-coastlines
205 Keep coastline data rather than filtering it out. By default
206 natural=coastline tagged data will be discarded based on the
207 assumption that Shapefiles generated by OSMCoastline
208 (https://osmdata.openstreetmap.de/) will be used.
209
210 --number-processes num
211 Specifies the number of parallel processes used for certain
212 operations. If disks are fast enough e.g. if you have an SSD,
213 then this can greatly increase speed of the "going over pending
214 ways" and "going over pending relations" stages on a multi-core
215 server.
216
217 -I|--disable-parallel-indexing
218 By default osm2pgsql initiates the index building on all tables
219 in parallel to increase performance. This can be disadvantages
220 on slow disks, or if you don't have enough RAM for PostgreSQL to
221 perform up to 7 parallel index building processes (e.g. because
222 maintenance_work_mem is set high).
223
224 --flat-nodes /path/to/nodes.cache
225 The flat-nodes mode is a separate method to store slim mode node
226 information on disk. Instead of storing this information in the
227 main PostgreSQL database, this mode creates its own separate
228 custom database to store the information. As this custom data‐
229 base has application level knowledge about the data to store and
230 is not general purpose, it can store the data much more effi‐
231 ciently. Storing the node information for the full planet
232 requires more than 300GB in PostgreSQL, the same data is stored
233 in "only" 50GB using the flat-nodes mode. This can also increase
234 the speed of applying diff files. This option activates the
235 flat-nodes mode and specifies the location of the database file.
236 It is a single large file. This mode is only recommended for
237 full planet imports as it doesn't work well with small imports.
238 The default is disabled.
239
240 -h|--help
241 Help information.
242 Add -v to display supported projections.
243
244 -v|--verbose
245 Verbose output.
246
248 Latlong (-l) SRS: 4326 (none)
249 Spherical Mercator (-m) SRS:3857 +proj=merc +a=6378137 +b=6378137
250 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null
251 +no_defs +over
252 EPSG-defined (-E) SRS: +init=epsg:(as given in parameter)
253
255 proj(1), postgres(1). osmcoastline(1).
256
258 osm2pgsql was written by Jon Burgess, Artem Pavlenko, and other Open‐
259 StreetMap project members.
260
261 This manual page was written by Andreas Putzo <andreas@putzo.net> for
262 the Debian project, and amended by OpenStreetMap authors.
263
264
265
266
267
268 Nevember 14, 2019 OSM2PGSQL(1)