Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork477
Import OpenStreetMap data into a PostgreSQL/PostGIS database
License
osm2pgsql-dev/osm2pgsql
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
osm2pgsql is a tool for loading OpenStreetMap data into a PostgreSQL / PostGISdatabase suitable for applications like rendering into a map, geocoding withNominatim, or general analysis.
See thedocumentation for instructions on howto install and run osm2pgsql.
- Converts OSM files to a PostgreSQL DB
- Conversion of tags to columns is configurable in the style file
- Able to read .gz, .bz2, .pbf and .o5m files directly
- Can apply diffs to keep the database up to date
- Support the choice of output projection
- Configurable table names
- Support for hstore field type to store the complete set of tags in one databasefield if desired
Most Linux distributions include osm2pgsql. It is available on macOS withHomebrew and Windows builds are also available. Seehttps://osm2pgsql.org/doc/install.html for details.
The latest source code is available in the osm2pgsql git repository on GitHuband can be downloaded as follows:
git clone https://github.com/openstreetmap/osm2pgsql.git
Osm2pgsql uses the cross-platformCMake build systemto configure and build itself.
Required libraries are
- CLI11
- expat
- proj
- bzip2
- zlib
- Boost libraries (for boost geometry)
- nlohmann/json
- OpenCV (Optional, for generalization only)
- potrace (Optional, for generalization only)
- PostgreSQL client libraries
- Lua
- Python (only for running tests)
- Psycopg (only for running tests)
The following libraries are included in thecontrib
directory. You can buildwith other versions of those libraries (set theEXTERNAL_*libname*
option toON
) but make sure you are using a compatible version:
It also requires access to a database server runningPostgreSQL (version 11+ works, 13+ stronglyrecommended) andPostGIS (version 3.0+).
Make sure you have installed the development packages for the librariesmentioned in the requirements section and a C++ compiler which supports C++17.We officially support gcc >= 10.0 and clang >= 13.
To rebuild the included man page you'll need thepandoctool.
First install the dependencies.
On a Debian or Ubuntu system, this can be done with:
sudo apt-get install make cmake g++ libboost-dev \ libexpat1-dev zlib1g-dev libpotrace-dev \ libopencv-dev libbz2-dev libpq-dev libproj-dev lua5.3 liblua5.3-dev \ pandoc nlohmann-json3-dev pyosmium
On a Fedora system, use
sudo dnf install cmake make gcc-c++ libtool boost-devel bzip2-devel \ expat-devel fmt-devel json-devel libpq-devel lua-devel zlib-devel \ potrace-devel opencv-devel python3-osmium \ postgresql-devel proj-devel proj-epsg pandoc
On RedHat / CentOS first runsudo yum install epel-release
then installdependencies with:
sudo yum install cmake make gcc-c++ boost-devel expat-devel zlib-devel \ potrace-devel opencv-devel json-devel python3-osmium \ bzip2-devel postgresql-devel proj-devel proj-epsg lua-devel pandoc
On a FreeBSD system, use
pkg install devel/cmake devel/boost-libs textproc/expat2 \ databases/postgresql94-client graphics/proj lang/lua52
On Alpine, use
apk --update-cache add cmake make g++ nlohmann-json \ postgresql-dev boost-dev expat-dev bzip2-dev zlib-dev \ libpq proj-dev lua5.3-dev luajit-dev
Once dependencies are installed, use CMake to build the Makefiles in a separatefolder:
mkdir build&&cd buildcmake ..
If some installed dependencies are not found by CMake, more options may needto be set. Typically, settingCMAKE_PREFIX_PATH
to a list of appropriatepaths is sufficient.
When the Makefiles have been successfully built, compile with
make
The man page can be rebuilt with:
make man
The compiled files can be installed with
sudo make install
By default, the Release build with debug info is created and no tests arecompiled. You can change that behavior by using additional options likefollowing:
cmake .. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON
Note thatDebug
builds will be much slower than release build. For productionRelease
orRelWithDebInfo
builds are recommended.
Osm2pgsql has builtin support for the Latlong (WGS84, EPSG:4326) and theWebMercator (EPSG:3857) projection. Other projections are supported throughtheProj library which is used by default. Set the CMakeoptionWITH_PROJ
toOFF
to disable use of that library.
To speed up Lua tag transformations,LuaJIT can beoptionally enabled on supported platforms. This can speed up processingconsiderably.
On a Debian or Ubuntu system install the LuaJIT library:
sudo apt-get install libluajit-5.1-dev
Configuration parameterWITH_LUAJIT=ON
needs to be added to enable LuaJIT.Otherwise make and installation steps are identical to the description above.
cmake -D WITH_LUAJIT=ON ..
Useosm2pgsql --version
to verify that the build includes LuaJIT support.The output should show something like
Lua 5.1.4 (LuaJIT 2.1.0-beta3)
There is some experimental support for data generalization. Seehttps://osm2pgsql.org/generalization/ for details.
If you have problems with osm2pgsql or want to report a bug, go tohttps://osm2pgsql.org/support/ .
This program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.
We welcome contributions to osm2pgsql. SeeCONTRIBUTING.mdandhttps://osm2pgsql.org/contribute/ for information on how to contribute.
About
Import OpenStreetMap data into a PostgreSQL/PostGIS database
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.