Name: osm2pgsql
Owner: Tilezen
Description: OpenStreetMap data to PostgreSQL converter
Forked from: openstreetmap/osm2pgsql
Created: 2016-08-04 21:18:25.0
Updated: 2016-08-04 21:18:27.0
Pushed: 2016-11-11 00:58:31.0
Size: 42917
Language: C++
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
osm2pgsql is a tool for loading OpenStreetMap data into a PostgreSQL / PostGIS database suitable for applications like rendering into a map, geocoding with Nominatim, or general analysis.
Most Linux distributions include osm2pgsql. It is also available on macOS with Homebrew. Unoffical builds for Windows are built by AppVeyor but you need to find the right build artifacts.
The latest source code is available in the OSM git repository on github and can be downloaded as follows:
t clone git://github.com/openstreetmap/osm2pgsql.git
Osm2pgsql uses the cross-platform CMake build system to configure and build itself and requires
Required libraries are
It also requires access to a database server running PostgreSQL 9.1+ and PostGIS 2.0+.
Make sure you have installed the development packages for the libraries mentioned in the requirements section and a C++ compiler which supports C++11. Both GCC 4.8 and Clang 3.4 meet this requirement.
First install the dependencies.
On a Debian or Ubuntu system, this can be done with:
apt-get install make cmake g++ libboost-dev libboost-system-dev \
bboost-filesystem-dev libexpat1-dev zlib1g-dev \
bbz2-dev libpq-dev libgeos-dev libgeos++-dev libproj-dev lua5.2 \
blua5.2-dev
On a Fedora system, use
yum install cmake gcc-c++ boost-devel expat-devel zlib-devel bzip2-devel \
stgresql-devel geos-devel proj-devel proj-epsg lua-devel
On RedHat / CentOS first run sudo yum install epel-release
then install
dependencies like on Fedora.
On a FreeBSD system, use
install devel/cmake devel/boost-libs textproc/expat2 \
tabases/postgresql94-client graphics/geos graphics/proj lang/lua52
Once dependencies are installed, use CMake to build the Makefiles in a separate folder
r build && cd build
e ..
If some installed dependencies are not found by CMake, more options may need
to be set. Typically, setting CMAKE_PREFIX_PATH
to a list of appropriate
paths is sufficient.
When the Makefiles have been successfully built, compile with
The compiled files can be installed with
make install
By default, the Release build with debug info is created and no tests are compiled. You can change that behavior by using additional options like following:
e .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON
Osm2pgsql has one program, the executable itself, which has 44 command line options.
Before loading into a database, the database must be created and the PostGIS and optional hstore extensions must be loaded. A full guide to PostgreSQL setup is beyond the scope of this readme, but with reasonably recent versions of PostgreSQL and PostGIS this can be done with
tedb gis
-d gis -c 'CREATE EXTENSION postgis; CREATE EXTENSION hstore;'
A basic invocation to load the data into the database gis
for rendering would be
pgsql --create --database gis data.osm.pbf
This will load the data from data.osm.pbf
into the planet_osm_point
,
planet_osm_line
, planet_osm_roads
, and planet_osm_polygon
tables.
When importing a large amount of data such as the complete planet, a typical command line would be
pgsql -c -d gis --slim -C <cache size> \
flat-nodes <flat nodes> planet-latest.osm.pbf
where
<cache size>
is about 75% of memory in MiB, to a maximum of about 30000. Additional RAM will not be used.<flat nodes>
is a location where a 24GiB file can be saved.The databases from either of these commands can be used immediately by Mapnik for rendering maps with standard tools like renderd/mod_tile, TileMill, Nik4, among others. It can also be used for spatial analysis or shapefile exports.
Additional documentation is available on writing command lines.
In addition to the standard pgsql backend designed for rendering there is also the gazetteer database for geocoding, principally with Nominatim, and the null backend for testing. For flexibility a new multi backend is also available which allows the configuration of custom PostgreSQL tables instead of those provided in the pgsql backend.
We welcome contributions to osm2pgsql. If you would like to report an issue, please use the issue tracker on GitHub.
More information can be found in CONTRIBUTING.md.
General queries can be sent to the tile-serving@ or dev@ mailing lists.