Difference between revisions of "PostGIS"

From ArchWiki
Jump to: navigation, search
(This document describes the process for installing PostGIS and creating a template PostGIS database.)
Line 1: Line 1:
This document describes the process for installing PostGIS and creating a template PostGIS database. For additional resources, check out the [http://postgis.refractions.net/documentation/ PostGIS Documentation].
+
This document describes the process for installing PostGIS and creating a template PostGIS database. It is assumed that PostgreSQL has been installed. If it hasn't, please refer to the [http://www.example.com PostgreSQL] page.
 +
 
 +
== Installing PostGIS ==
 +
*Install PostGIS
 +
$ su
 +
$ pacman -Sy postgis
 +
 
 +
== Creating a Template PostGIS Database ==
 +
*Become the postgres user.
 +
$ su - postgres
 +
*If you haven't created a superuser for accessing PostgreSQL, you may want do that now. You will be prompted for granting permissions.
 +
$ createuser [username]
 +
*Create a new database called "template_postgis" ("-E UTF-8" optional).
 +
$ createdb -O [username] template_postgis -E UTF-8
 +
*PostGIS requires the pl/pgSQL language.
 +
$ createlang plpgsql template_postgis
 +
*Load the PostGIS spatial types for PostgreSQL and spatial reference systems. "lwpostgis.sql" and "spatial_ref_sys.sql" are part of the installation of PostGIS, and may reside somewhere else besides "/usr/share" depending on the installation.
 +
$ psql -d template_postgis -f /usr/share/lwpostgis.sql
 +
$ psql -d template_postgis -f /usr/share/spatial_ref_sys.sql
 +
 
 +
== Creating a PostGIS Database From the Template==
 +
*It's common practice to reserve a bare template for creating new PostGIS databases.
 +
$ createdb -T template_postgis [new_postgis_db]
 +
 
 +
For additional resources concerning PostGIS, check out the [http://postgis.refractions.net/documentation/ PostGIS Documentation].

Revision as of 23:57, 13 September 2009

This document describes the process for installing PostGIS and creating a template PostGIS database. It is assumed that PostgreSQL has been installed. If it hasn't, please refer to the PostgreSQL page.

Installing PostGIS

  • Install PostGIS
$ su
$ pacman -Sy postgis

Creating a Template PostGIS Database

  • Become the postgres user.
$ su - postgres
  • If you haven't created a superuser for accessing PostgreSQL, you may want do that now. You will be prompted for granting permissions.
$ createuser [username]
  • Create a new database called "template_postgis" ("-E UTF-8" optional).
$ createdb -O [username] template_postgis -E UTF-8
  • PostGIS requires the pl/pgSQL language.
$ createlang plpgsql template_postgis
  • Load the PostGIS spatial types for PostgreSQL and spatial reference systems. "lwpostgis.sql" and "spatial_ref_sys.sql" are part of the installation of PostGIS, and may reside somewhere else besides "/usr/share" depending on the installation.
$ psql -d template_postgis -f /usr/share/lwpostgis.sql
$ psql -d template_postgis -f /usr/share/spatial_ref_sys.sql

Creating a PostGIS Database From the Template

  • It's common practice to reserve a bare template for creating new PostGIS databases.
$ createdb -T template_postgis [new_postgis_db]

For additional resources concerning PostGIS, check out the PostGIS Documentation.