PostGIS

From OpenStreetMap Wiki
Jump to: navigation, search
Help
Available languages
English Italiano Русский

PostGIS is an extension for the PostgreSQL database. PostgreSQL already has geometry types[1]. PostGIS adds geospatial functions and two metadata tables which makes it pretty easy to handle spatial data in the database.

In the OSM project PostGIS is used for creating maps with Mapnik[2], many other people also use PostGIS for other tasks. The central OSM database was a MySQL database until API 0.5, since API 0.6 it is a PostgreSQL database, but currently not using the PostGIS extension.

Contents

Use with Mapnik

The Mapnik renderer uses a PostGIS database as data source. OSM data is imported into PostGIS using the Osm2pgsql program.

The database schema is optimized for Mapnik use. It contains the tables

for point, line and polygon features, respectively. In addition there is a table planet_osm_roads for some line features just shown on some zoom levels. (The naming of this table is historic, it contains more than just roads.) Osm2pgsql has a config file that describes which features with which tags should end up in those tables. Not all OSM data ends up in the database!

Use with Osmosis

Osmosis can import OSM data into PostGIS using the --write-pgsql and --write-pgsql-dump command line arguments.

The database schema is similar to the database schema in the main database. It contains the following tables: nodes, ways, relations, node_tags, way_tags, relation_tags, way_nodes, relation_members, users. There are no tables for historic data, only for the current data.

See also

References

  1. PostGIS project page
  2. Mapnik project page
Personal tools
Namespaces
Variants
Actions
site
Toolbox