LinuxCommandLibrary

osm2pgsql

TLDR

Import OSM data

$ osm2pgsql -d [database] [file.osm.pbf]
copy
Import with slim mode
$ osm2pgsql -d [database] -s [file.osm.pbf]
copy
Import with custom style
$ osm2pgsql -d [database] -S [style.lua] [file.osm.pbf]
copy
Append new data
$ osm2pgsql -d [database] -a [updates.osc]
copy
Set number of processes
$ osm2pgsql -d [database] -j [4] [file.osm.pbf]
copy

SYNOPSIS

osm2pgsql [options] file...

DESCRIPTION

osm2pgsql imports OpenStreetMap data into a PostgreSQL/PostGIS database. It's commonly used to create databases for rendering map tiles with Mapnik.
The tool can handle full planet imports and incremental updates.

PARAMETERS

-d database

Database name.
-s, --slim
Store temp data in database.
-S file
Style file.
-a, --append
Append mode.
-c, --create
Create tables (default).
-j num
Number of processes.
-C MB
Cache size.
-H host
Database host.
-U user
Database user.

TYPICAL WORKFLOW

$ # Create database
createdb gis
psql -d gis -c "CREATE EXTENSION postgis;"

# Import data
osm2pgsql -d gis -s -C 2000 planet.osm.pbf
copy

CAVEATS

Requires PostGIS. Planet imports need substantial resources. Use slim mode for updates.

HISTORY

osm2pgsql was developed for the OpenStreetMap project to enable map rendering from OSM data using PostgreSQL.

SEE ALSO

imposm(1), osmosis(1), postgresql(1), postgis(1)

Copied to clipboard