Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a spatially enabled PostGIS database. I am following the PostGIS documentation,

In the short version, i executed,

createdb yourdatabase
createlang plpgsql yourdatabase

But I did not execute the last three commands,

psql -d yourdatabase -f postgis.sql
psql -d yourdatabase -f postgis_comments.sql
psql -d yourdatabase -f spatial_ref_sys.sql

Is my database still spatially enabled? If not, then can you tell me where these .sql files are located so I can execute those last commands, since I am getting the following error,

postgis.sql: No such file or directory

I am using Ubuntu 12.04

share|improve this question
to find your postgis.sql file run "locate postgis.sql" from bash (without the quotes). – Kelso Jul 18 '12 at 6:41
up vote 14 down vote accepted

While your database is technically spatial at this point, you would only be working with the inbuilt pg geometry types.

In order to complete your installation, you do need to run the scripts as suggested.

You can find them in your /usr/share/postgresql/[version number]/contrib/ postgis sub-directory.

You should see the following:

legacy_minimal.sql    postgis_upgrade_20_minor.sql    spatial_ref_sys.sql
legacy.sql            raster_comments.sql             topology_comments.sql
postgis_comments.sql  rtpostgis_legacy.sql            uninstall_legacy.sql    rtpostgis.sql                   uninstall_postgis.sql
postgis.sql           rtpostgis_upgrade_20_minor.sql  uninstall_rtpostgis.sql
share|improve this answer

If you have Ubuntu 12.04, then you should have PostgreSQL 9.1, which makes things awesome for PostGIS 2.0, where you can use use the new EXTENSION framework. To spatially enable a database, use the DDL from a SQL window:


See other details for installing PostGIS 2.0 from source for Ubuntu 12.04 here.

If you are using PostGIS 1.5, you will need the enabler scripts on "mydb", run from the shell:

sudo -u postgres createdb mydb
sudo -u postgres psql -d mydb -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
sudo -u postgres psql -d mydb -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
sudo -u postgres psql -d mydb -f /usr/share/postgresql/9.1/contrib/postgis_comments.sql
share|improve this answer
i actually did goto the /usr/share/postgresql/8.4/contrib/ and found the .sql files there – Sam007 Jul 18 '12 at 16:12
For using geometry functions like ST_Transform and creating geometry columns the user will also need GRANT SELECT ON spatial_ref_sys TO PUBLIC; GRANT ALL ON geometry_columns TO <my desired user>; – geekQ Apr 2 '13 at 10:36
You can also run SELECT postgis_full_version(); afterwards to check that a database is spatially-enabled. – XåpplI'-I0llwlg'I - Nov 20 '14 at 6:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.