Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to create a spatially enabled PostGIS database. I am following the PostGIS documentation, http://postgis.net/docs/manual-1.5/ch02.html#id2648455.

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
2  
to find your postgis.sql file run "locate postgis.sql" from bash (without the quotes). –  Kelso Jul 18 '12 at 6:41

2 Answers 2

up vote 13 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
postgis_restore.pl    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:

CREATE EXTENSION postgis;

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
2  
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 at 6:15

Your Answer

 
discard

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.