From OpenStreetMap Wiki
(Redirected from Postgis)
Jump to: navigation, search
Available languages — PostGIS
Afrikaans Alemannisch aragonés asturianu azərbaycanca Bahasa Indonesia Bahasa Melayu Bân-lâm-gú Basa Jawa Baso Minangkabau bosanski brezhoneg català čeština dansk Deutsch eesti English español Esperanto estremeñu euskara français Frysk Gaeilge Gàidhlig galego Hausa hrvatski Igbo interlingua Interlingue isiXhosa isiZulu íslenska italiano Kiswahili Kreyòl ayisyen kréyòl gwadloupéyen kurdî latviešu Lëtzebuergesch lietuvių magyar Malagasy Malti Nederlands Nedersaksies norsk norsk nynorsk occitan Oromoo oʻzbekcha/ўзбекча Plattdüütsch polski português română shqip slovenčina slovenščina Soomaaliga suomi svenska Tiếng Việt Türkçe Vahcuengh vèneto Wolof Yorùbá Zazaki српски / srpski беларуская български қазақша македонски монгол русский тоҷикӣ українська Ελληνικά Հայերեն ქართული नेपाली मराठी हिन्दी অসমীয়া বাংলা ਪੰਜਾਬੀ ગુજરાતી ଓଡ଼ିଆ தமிழ் తెలుగు ಕನ್ನಡ മലയാളം සිංහල ไทย မြန်မာဘာသာ ລາວ ភាសាខ្មែរ ⵜⴰⵎⴰⵣⵉⵖⵜ አማርኛ 한국어 日本語 中文(简体)‎ 吴语 粵語 中文(繁體)‎ ייִדיש עברית اردو العربية پښتو سنڌي فارسی ދިވެހިބަސް

PostGIS ( is an extension for the PostgreSQL database. PostgreSQL already has basic geometry types. PostGIS adds additional geospatial types and functions which make handling spatial data in the database easier and more powerful.

In the OSM project PostGIS is used for creating maps with Mapnik; many other people also use PostGIS for other tasks. PostGIS and Mapnik power most of the popular OpenStreetMap maps, including the four main layers on the OSM website.

Setting up

Note: the PostGIS installation snippets are currently (as of March 2013) spread over many tool specific pages (just google for 'spatial_ref_sys.sql'). These snippets possess different levels of completeness and actuality. Bundling the description under the PostGIS wiki page could enable better maintenance due to a bigger user base. Let's create HOWTOs for current software versions and later migrate the installation instructions from all over the wiki.

Following steps will bring you from a freshly installed computer to a PostGIS enabled database with OpenStreetMap data:

1. Install PostgreSQL with PostGIS extension. The procedure depends on OS, OS version and desired Postgres and PostGIS version. Detailed howtos PostGIS/Installation.

2. Creating db user and database(s). Depends on how you are going to access the database (locally or remotely). How many users? Which access rights for different users? PostGIS/Installation#Create database

3. Spatially enabling the database(s) PostGIS/Installation#Activate PostGIS. This step is required for every database you create. You are ready if you are able to use GIS specific functions like

select postgis_full_version();
select ST_Point(1, 2) AS MyFirstPoint;
select ST_SetSRID(ST_Point(-77.036548, 38.895108),4326); -- using WGS 84

4. Import OSM data using Osm2pgsql, Imposm, Osmium, or other methods. With Osmosis, use 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