Skip to content

Instantly share code, notes, and snippets.

@asmedrano
Created July 23, 2013 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asmedrano/6065275 to your computer and use it in GitHub Desktop.
Save asmedrano/6065275 to your computer and use it in GitHub Desktop.
Installing postgis on ubuntu 13.04
sudo add-apt-repository ppa:ubuntugis
sudo apt-get update
sudo apt-get install postgis postgresql-9.1-postgis
# youll need this /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
# and this /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
# now create a spatially enabled template db
The first step in creating a PostGIS database is to create a simple PostgreSQL database.
createdb [yourdatabase]
Many of the PostGIS functions are written in the PL/pgSQL procedural language. As such, the next step to create a PostGIS database is to enable the PL/pgSQL language in your new database. This is accomplish by the command
createlang plpgsql [yourdatabase/ i use template_postgis]
Now load the PostGIS object and function definitions into your database by loading the postgis.sql definitions file (located in [prefix]/share/contrib as specified during the configuration step).
psql -d template_postgis -f /path/to/postgis.sql
For a complete set of EPSG coordinate system definition identifiers, you can also load the spatial_ref_sys.sql definitions file and populate the spatial_ref_sys table. This will permit you to perform ST_Transform() operations on geometries.
psql -d template_postgis -f /path/to/spatial_ref_sys.sql
If you wish to add comments to the PostGIS functions, the final step is to load the postgis_comments.sql into your spatial database. The comments can be viewed by simply typing \dd [function_name] from a psql terminal window.
# NOw you can use that template to create other dbs.
createdb -T template_postgis my_new_db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment