|
| 1 | +--- |
| 2 | +version: 2.2.0 |
| 3 | +program: osm2pgsql |
| 4 | +title: osm2pgsql 2.2.0 |
| 5 | +--- |
| 6 | +{::options header_offset="1"/} |
| 7 | + |
| 8 | + |
| 9 | +# NAME |
| 10 | + |
| 11 | +osm2pgsql - OpenStreetMap data to PostgreSQL converter |
| 12 | + |
| 13 | +# SYNOPSIS |
| 14 | + |
| 15 | +**osm2pgsql** \[*OPTIONS*\] OSM-FILE... |
| 16 | + |
| 17 | +# DESCRIPTION |
| 18 | + |
| 19 | +**osm2pgsql** imports OpenStreetMap data into a PostgreSQL/PostGIS database. It |
| 20 | +is an essential part of many rendering toolchains, the Nominatim geocoder and |
| 21 | +other applications processing OSM data. |
| 22 | + |
| 23 | +**osm2pgsql** can run in either "create" mode (the default) or in "append" mode |
| 24 | +(option **-a, \--append**). |
| 25 | + |
| 26 | +In "create" mode osm2pgsql will create the database tables required by the |
| 27 | +configuration and import the OSM file(s) specified on the command line into |
| 28 | +those tables. Note that you also have to use the **-s, \--slim** option if you |
| 29 | +want your database to be updatable. |
| 30 | + |
| 31 | +In "append" mode osm2pgsql will update the database tables with the data from |
| 32 | +OSM change files specified on the command line. |
| 33 | + |
| 34 | +This man page can only cover some of the basics and describe the command line |
| 35 | +options. See the [Osm2pgsql Manual](https://osm2pgsql.org/doc/manual.html) for |
| 36 | +more information. |
| 37 | + |
| 38 | +# OPTIONS |
| 39 | + |
| 40 | +This program follows the usual GNU command line syntax, with long options |
| 41 | +starting with two dashes (`--`). Mandatory arguments to long options are |
| 42 | +mandatory for short options too. |
| 43 | + |
| 44 | +# MAIN OPTIONS |
| 45 | + |
| 46 | +-a, \--append |
| 47 | +: Run in append mode. Adds the OSM change file into the database without |
| 48 | + removing existing data. |
| 49 | + |
| 50 | +-c, \--create |
| 51 | +: Run in create mode. This is the default if **-a, \--append** is not |
| 52 | + specified. Removes existing data from the database tables! |
| 53 | + |
| 54 | +# HELP/VERSION OPTIONS |
| 55 | + |
| 56 | +-h, \--help |
| 57 | +: Print help. |
| 58 | + |
| 59 | +-V, \--version |
| 60 | +: Print osm2pgsql version. |
| 61 | + |
| 62 | +# LOGGING OPTIONS |
| 63 | + |
| 64 | +\--log-level=LEVEL |
| 65 | +: Set log level ('debug', 'info' (default), 'warn', or 'error'). |
| 66 | + |
| 67 | +\--log-progress=VALUE |
| 68 | +: Enable (`true`) or disable (`false`) progress logging. Setting this to |
| 69 | + `auto` will enable progress logging on the console and disable it |
| 70 | + if the output is redirected to a file. Default: true. |
| 71 | + |
| 72 | +\--log-sql |
| 73 | +: Enable logging of SQL commands for debugging. |
| 74 | + |
| 75 | +\--log-sql-data |
| 76 | +: Enable logging of all data added to the database. This will write out |
| 77 | + a huge amount of data! For debugging. |
| 78 | + |
| 79 | +-v, \--verbose |
| 80 | +: Same as `--log-level=debug`. |
| 81 | + |
| 82 | +# DATABASE OPTIONS |
| 83 | + |
| 84 | +-d, \--database=NAME |
| 85 | +: The name of the PostgreSQL database to connect to. If this parameter |
| 86 | + contains an `=` sign or starts with a valid URI prefix (`postgresql://` or |
| 87 | + `postgres://`), it is treated as a conninfo string. See the PostgreSQL |
| 88 | + manual for details. |
| 89 | + |
| 90 | +-U, \--username=NAME, \--user=NAME |
| 91 | +: Postgresql user name. |
| 92 | + |
| 93 | +-W, \--password |
| 94 | +: Force password prompt. |
| 95 | + |
| 96 | +-H, \--host=HOSTNAME |
| 97 | +: Database server hostname or unix domain socket location. |
| 98 | + |
| 99 | +-P, \--port=PORT |
| 100 | +: Database server port. |
| 101 | + |
| 102 | +\--schema=SCHEMA |
| 103 | +: Default for various schema settings throughout osm2pgsql (default: `public`). |
| 104 | + The schema must exist in the database and be writable by the database user. |
| 105 | + |
| 106 | +# INPUT OPTIONS |
| 107 | + |
| 108 | +-r, \--input-reader=FORMAT |
| 109 | +: Select format of the input file. Available choices are **auto** |
| 110 | + (default) for autodetecting the format, |
| 111 | + **xml** for OSM XML format files, **o5m** for o5m formatted files |
| 112 | + and **pbf** for OSM PBF binary format. |
| 113 | + |
| 114 | +-b, \--bbox=MINLON,MINLAT,MAXLON,MAXLAT |
| 115 | +: Apply a bounding box filter on the imported data. Example: |
| 116 | + **\--bbox** **-0.5,51.25,0.5,51.75** |
| 117 | + |
| 118 | +# MIDDLE OPTIONS |
| 119 | + |
| 120 | +-i, \--tablespace-index=TABLESPC |
| 121 | +: Store all indexes in the PostgreSQL tablespace `TABLESPC`. This option |
| 122 | + also affects the tables created by the pgsql output. This option is |
| 123 | + deprecated. Use the \--tablespace-slim-index and/or \--tablespace-main-index |
| 124 | + options instead. |
| 125 | + |
| 126 | +\--tablespace-slim-data=TABLESPC |
| 127 | +: Store the slim mode tables in the given tablespace. |
| 128 | + |
| 129 | +\--tablespace-slim-index=TABLESPC |
| 130 | +: Store the indexes of the slim mode tables in the given tablespace. |
| 131 | + |
| 132 | +-p, \--prefix=PREFIX |
| 133 | +: Prefix for table names (default: `planet_osm`). |
| 134 | + |
| 135 | +-s, \--slim |
| 136 | +: Store temporary data in the database. Without this mode, all temporary data is stored in |
| 137 | + RAM and if you do not have enough the import will not work successfully. With slim mode, |
| 138 | + you should be able to import the data even on a system with limited RAM, although if you |
| 139 | + do not have enough RAM to cache at least all of the nodes, the time to import the data |
| 140 | + will likely be greatly increased. |
| 141 | + |
| 142 | +\--drop |
| 143 | +: Drop the slim mode tables from the database and the flat node file once the import is complete. This can |
| 144 | + greatly reduce the size of the database, as the slim mode tables typically are the same |
| 145 | + size, if not slightly bigger than the main tables. It does not, however, reduce the |
| 146 | + maximum spike of disk usage during import. It can furthermore increase the import speed, |
| 147 | + as no indexes need to be created for the slim mode tables, which (depending on hardware) |
| 148 | + can nearly halve import time. Slim mode tables however have to be persistent if you want |
| 149 | + to be able to update your database, as these tables are needed for diff processing. |
| 150 | + |
| 151 | +-C, \--cache=NUM |
| 152 | +: Only for slim mode: Use up to **NUM** MB of RAM for caching nodes. Giving osm2pgsql sufficient cache |
| 153 | + to store all imported nodes typically greatly increases the speed of the import. Each cached node |
| 154 | + requires 8 bytes of cache, plus about 10% - 30% overhead. As a rule of thumb, |
| 155 | + give a bit more than the size of the import file in PBF format. If the RAM is not |
| 156 | + big enough, use about 75% of memory. Make sure to leave enough RAM for PostgreSQL. |
| 157 | + It needs at least the amount of `shared_buffers` given in its configuration. |
| 158 | + Defaults to 800. |
| 159 | + |
| 160 | +-x, \--extra-attributes |
| 161 | +: Include attributes of each object in the middle tables and make them |
| 162 | + available to the outputs. Attributes are: user name, user id, changeset id, |
| 163 | + timestamp and version. |
| 164 | + |
| 165 | +-F, \--flat-nodes=FILENAME |
| 166 | +: Use a file on disk to store node locations instead of storing them in |
| 167 | + memory (in non-slim mode) or in the database (in slim mode). This is much |
| 168 | + more efficient than storing the data in the database. |
| 169 | + Storing the node information for the full |
| 170 | + planet requires more than 500GB in PostgreSQL, the same data is stored in "only" 90GB using |
| 171 | + the flat-nodes mode. This can also increase the speed of applying diff files. This option |
| 172 | + activates the flat-nodes mode and specifies the location of the database file. It is a |
| 173 | + single large file. This mode is only recommended for full planet imports |
| 174 | + as it doesn't work well with small imports. The default is disabled. The |
| 175 | + file will stay on disk after import, use \--drop to remove it (but you |
| 176 | + can't do updates then). |
| 177 | + |
| 178 | +\--middle-schema=SCHEMA |
| 179 | +: Use PostgreSQL schema SCHEMA for all tables, indexes, and functions in the |
| 180 | + middle. The schema must exist in the database and be writable by the |
| 181 | + database user. By default the schema set with `--schema` is used, or |
| 182 | + `public` if that is not set. |
| 183 | + |
| 184 | +\--middle-with-nodes |
| 185 | +: When a flat nodes file is used, nodes are not stored in the database. Use |
| 186 | + this option to force storing nodes with tags in the database, too. |
| 187 | + |
| 188 | +# OUTPUT OPTIONS |
| 189 | + |
| 190 | +-O, \--output=OUTPUT |
| 191 | +: Specifies the output to use. Currently osm2pgsql supports **pgsql**, |
| 192 | + **flex**, and **null**. **pgsql** is the default output still available for |
| 193 | + backwards compatibility. New setups should use the **flex** output which |
| 194 | + allows for a much more flexible configuration. The **null** output does not |
| 195 | + write anything and is only useful for testing or with **\--slim** for |
| 196 | + creating slim tables. |
| 197 | + |
| 198 | +-S, \--style=FILE |
| 199 | +: The style file. This specifies how the data is imported into the database, |
| 200 | + its format depends on the output. (For the **pgsql** output, the default is |
| 201 | + `/usr/share/osm2pgsql/default.style`, for other outputs there is no |
| 202 | + default.) |
| 203 | + |
| 204 | +# PGSQL OUTPUT OPTIONS |
| 205 | + |
| 206 | +\--tablespace-main-data=TABLESPC |
| 207 | +: Store the data tables in the PostgreSQL tablespace `TABLESPC`. |
| 208 | + |
| 209 | +\--tablespace-main-index=TABLESPC |
| 210 | +: Store the indexes in the PostgreSQL tablespace `TABLESPC`. |
| 211 | + |
| 212 | +\--latlong |
| 213 | +: Store coordinates in degrees of latitude & longitude. |
| 214 | + |
| 215 | +-m, \--merc |
| 216 | +: Store coordinates in Spherical Mercator (Web Mercator, EPSG:3857) |
| 217 | + (the default). |
| 218 | + |
| 219 | +-E, \--proj=SRID |
| 220 | +: Use projection EPSG:SRID. |
| 221 | + |
| 222 | +-p, \--prefix=PREFIX |
| 223 | +: Prefix for table names (default: `planet_osm`). This option affects the |
| 224 | + middle as well as the pgsql output table names. |
| 225 | + |
| 226 | +\--tag-transform-script=SCRIPT |
| 227 | +: Specify a Lua script to handle tag filtering and normalisation. The script |
| 228 | + contains callback functions for nodes, ways and relations, which each take |
| 229 | + a set of tags and returns a transformed, filtered set of tags which are |
| 230 | + then written to the database. |
| 231 | + |
| 232 | +-x, \--extra-attributes |
| 233 | +: Include attributes (user name, user id, changeset id, timestamp and version). |
| 234 | + This also requires additional entries in your style file. |
| 235 | + |
| 236 | +-k, \--hstore |
| 237 | +: Add tags without column to an additional hstore (key/value) column in |
| 238 | + the database tables. |
| 239 | + |
| 240 | +-j, \--hstore-all |
| 241 | +: Add all tags to an additional hstore (key/value) column in the database |
| 242 | + tables. |
| 243 | + |
| 244 | +-z, \--hstore-column=PREFIX |
| 245 | +: Add an additional hstore (key/value) column named `PREFIX` containing all |
| 246 | + tags that have a key starting with `PREFIX`, eg `\--hstore-column "name:"` |
| 247 | + will produce an extra hstore column that contains all `name:xx` tags. |
| 248 | + |
| 249 | +\--hstore-match-only |
| 250 | +: Only keep objects that have a value in at least one of the non-hstore |
| 251 | + columns. |
| 252 | + |
| 253 | +\--hstore-add-index |
| 254 | +: Create indexes for all hstore columns after import. |
| 255 | + |
| 256 | +-G, \--multi-geometry |
| 257 | +: Normally osm2pgsql splits multi-part geometries into separate database rows |
| 258 | + per part. A single OSM object can therefore use several rows in the output |
| 259 | + tables. With this option, osm2pgsql instead generates multi-geometry |
| 260 | + features in the PostgreSQL tables. |
| 261 | + |
| 262 | +-K, \--keep-coastlines |
| 263 | +: Keep coastline data rather than filtering it out. By default objects |
| 264 | + tagged `natural=coastline` will be discarded based on the assumption that |
| 265 | + Shapefiles generated by OSMCoastline (https://osmdata.openstreetmap.de/) |
| 266 | + will be used for the coastline data. |
| 267 | + |
| 268 | +\--reproject-area |
| 269 | +: Compute area column using spherical mercator coordinates even if a |
| 270 | + different projection is used for the geometries. |
| 271 | + |
| 272 | +\--output-pgsql-schema=SCHEMA |
| 273 | +: Use PostgreSQL schema SCHEMA for all tables, indexes, and functions in the |
| 274 | + pgsql output. The schema must exist in the database and be writable by the |
| 275 | + database user. By default the schema set with `--schema` is used, or |
| 276 | + `public` if that is not set. |
| 277 | + |
| 278 | +# EXPIRE OPTIONS |
| 279 | + |
| 280 | +-e, \--expire-tiles=[MIN_ZOOM-]MAX-ZOOM |
| 281 | +: Create a tile expiry list. |
| 282 | + |
| 283 | +-o, \--expire-output=FILENAME |
| 284 | +: Output file name for expired tiles list. |
| 285 | + |
| 286 | +\--expire-bbox-size=SIZE |
| 287 | +: Max size for a polygon to expire the whole polygon, not just the boundary. |
| 288 | + |
| 289 | +# ADVANCED OPTIONS |
| 290 | + |
| 291 | +-I, \--disable-parallel-indexing |
| 292 | +: Disable parallel clustering and index building on all tables, build one |
| 293 | + index after the other. |
| 294 | + |
| 295 | +\--number-processes=THREADS |
| 296 | +: Specifies the number of parallel threads used for certain operations. |
| 297 | + |
| 298 | +# SEE ALSO |
| 299 | + |
| 300 | +* [osm2pgsql website](https://osm2pgsql.org) |
| 301 | +* [osm2pgsql manual](https://osm2pgsql.org/doc/manual.html) |
| 302 | +* **postgres**(1) |
| 303 | +* **osmcoastline**(1) |
| 304 | + |
0 commit comments