Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgis install [closed]

I have Postgres version 8.4.8

select version();
PostgreSQL 8.4.8 on i686-pc-linux-gnu, compiled by GCC gcc-4.4.real (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5, 32-bit

Installed Postgis via the synaptic package manager, (postgis and postgresql-8.4-postgis) everything seemed to go fine. Then when I try to verify the Postgis version, things are not fine. Both of these give the same error.

SELECT PostGIS_version();
SELECT PostGIS_full_version();

ERROR:  function postgis_full_version() does not exist
LINE 1: SELECT PostGIS_full_version();
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

The package manager claims Postgis is installed. How can I verify that the install worked or didn't work ?

like image 229
Orn Kristjansson Avatar asked Dec 10 '11 19:12

Orn Kristjansson


People also ask

How do you check PostGIS is installed or not?

You can find the version installed by issuing a select PostGIS_full_version(); query with psql or another tool. To install the absolute latest version of PostGIS, you can use the following commands.

Is PostGIS faster than QGIS?

PostGIS = very fast. Barcharts don't lie. As you can see from the graph earlier, it took PostGIS less than 10 % of the time to do the same analysis compared to QGIS and a Shapefile. If you are a GIS analyst and do processes like this every day, that can save you quite a lot of time in a year.


1 Answers

PostGIS needs to be installed per database. Existing databases are not altered automatically. Run the install script as follows.

In PostgreSQL 8.4 you may also need to create the language plpgsql. For 9.0+ it is the default procedural language and installed automatically. In your database:

createlang plpgsql yourdatabase

Can't do harm. If plpgsql is already installed it will just yield an error telling you so. Go to the install dir. In Debian Squeeze the contrib packages lie here (may be different in Ubuntu). In a shell:

cd /usr/share/postgresql/8.4/contrib/postgis-1.5

Then execute (as postgres user or you have to provide username / pw):

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

You may also want to install the comments to your shiny new functions (optional). In Debian Squeeze the install file lies in the /contrib main directory:

cd /usr/share/postgresql/8.4/contrib
psql -d yourdatabase -f postgis_comments.sql

If you want PostGIS to be installed with every new database in the cluster by default, install it to your template1 database also. Read more about that in the manual.

Sources for PostGIS installation (on Ubuntu):

http://postgis.net/docs/manual-2.1/postgis_installation.html
http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/

PostgreSQL 9.1+

With PostgreSQL 9.1 or newer you can use the more convenient CREATE EXTENSION:

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;

Your distribution is probably shipping the extension ready for installation. If not, consider the chapter "Building PostGIS Extensions and Deploying them" in the PostGIS manual.

like image 78
Erwin Brandstetter Avatar answered Sep 21 '22 14:09

Erwin Brandstetter