GithubHelp home page GithubHelp logo

gongfupanada / osm2pgsql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from osm2pgsql-dev/osm2pgsql

0.0 1.0 0.0 33.08 MB

OpenStreetMap data to PostgreSQL converter

Home Page: http://wiki.openstreetmap.org/wiki/Osm2pgsql

License: GNU General Public License v2.0

C++ 92.07% Shell 0.88% Lua 0.77% Python 6.00% C 0.28%

osm2pgsql's Introduction

osm2pgsql

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.

Features

  • 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
  • Gazetteer back-end for Nominatim
  • Support for hstore field type to store the complete set of tags in one database field if desired

Installing

The latest source code is available in the OSM git repository on github and can be downloaded as follows:

$ git clone git://github.com/openstreetmap/osm2pgsql.git

Building

Osm2pgsql uses the GNU Build System to configure and build itself and requires

It also requires access to a database server running PostgreSQL and PostGIS.

Make sure you have installed the development packages for the libraries mentioned in the requirements section and a C and C++ compiler.

To install on a Debian or Ubuntu system, first install the prerequisites:

sudo apt-get install autoconf automake libtool make g++ libboost-dev \
  libboost-system-dev libboost-filesystem-dev libboost-thread-dev libxml2-dev \
  libgeos-dev libgeos++-dev libpq-dev libbz2-dev libproj-dev
  protobuf-c-compiler libprotobuf-c0-dev lua5.2 liblua5.2-dev

To install on a Fedora system, use

sudo yum install gcc-c++ boost-devel libxml2-devel geos-devel \
  postgresql-devel bzip2-devel proj-devel protobuf-compiler

Then you should be able to bootstrap the build system:

./autogen.sh

And then run the standard GNU build install:

./configure && make && make install

Please see ./configure --help for more options on how to control the build process.

Usage

Osm2pgsql has one program, the executable itself, which has 43 command line options.

Before loading into a database, the database must be created and the PostGIS and optionally 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

createdb gis
psql -d gis -c 'CREATE EXTENSION postgis; CREATE EXTENSION hstore;'

A basic invocation to load the data into the database gis for rendering would be

osm2pgsql --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

osm2pgsql -c -d gis --slim -C <cache size> \
  --flat-nodes <flat nodes> planet-latest.osm.pbf

where

  • <cache size> is 24000 on machines with 32GiB or more RAM or about 75% of memory in MiB on machines with less
  • <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.

Alternate backends

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.

Any questions should be directed at the osm dev list http://wiki.openstreetmap.org/index.php/Mailing_lists

Testing

The code also comes with a suite of tests which can be run by executing make check.

Some of these tests depend on being able to set up a database and run osm2pgsql against it. You need to ensure that PostgreSQL is running and that your user is a superuser of that system. To do that, run:

sudo -u postgres createuser -s $USER
sudo mkdir -p /tmp/psql-tablespace
sudo chown postgres.postgres /tmp/psql-tablespace
psql -c "CREATE TABLESPACE tablespacetest LOCATION '/tmp/psql-tablespace'" postgres

Once this is all set up, all the tests should run (no SKIPs), and pass (no FAILs). If you encounter a failure, you can find more information by looking in the test-suite.log. If you find something which seems to be a bug, please check to see if it is a known issue at https://github.com/openstreetmap/osm2pgsql/issues and, if it's not already known, report it there.

Contributing

We welcome contributions to osm2pgsql. If you would like to report an issue, please use the issue tracker on GitHub.

General queries can be sent to the tile-serving@ or dev@ mailing lists.

osm2pgsql's People

Contributors

apmon avatar jburgess777 avatar kevinkreiser avatar zerebubuth avatar twain47 avatar pnorman avatar woodpeck avatar lonvia avatar hollinger avatar artemp avatar jocelynj avatar ravualhemio avatar joto avatar rodo avatar schuyler avatar stevec avatar tomhughes avatar gravitystorm avatar keithsharp avatar nickw1 avatar mojodna avatar mazdermind avatar nicolas17 avatar rachekalmir avatar avar avatar davideberra avatar alex85k avatar timwaters avatar simonpoole avatar rmarianski avatar

Watchers

gongfuPanda avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.