[GIS] Postgis installation

debianinstallationpostgis

I am installing Postgis on my Debian server, following these instructions:

http://postgis.net/install/ (Ubuntu / Debian)

https://wiki.postgresql.org/wiki/Apt

However, after following the instructions it looks like I have installed PostGres (9.4), but no PostGIS.

Do I have to install something more that was omitted in the instructions?

Can I somehow add PostGIS as a PostGres Plugin / Extension?

Best Answer

I did an extensive blog post on installing PostgreSQL 9.3/PostGIS 2.1 a few months ago at http://geospatial.commons.gc.cuny.edu/2014/10/25/installing-postgresqlpostgis-on-linux-mint-17/. It's not immediately clear to me what went wrong in your case, because you haven't really described what you did. In particular, the PostGIS installation instructions you link to describe compiling from source, as well as using the official repositories, and you don't say what you did. The fact that you are getting the message that postgis.control is missing when you try CREATE EXTENSION postgis; seems to imply that you have not successfully installed the PostGIS package. You could try

dpkg-query -l postgis

and see if it returns

ii  postgis        2.1.3+dfsg-3 i386         Geographic objects support for Po

or any other version.

If PostGIS is not in fact installed you can install from the PostgreSQL repository, which, if you have followed the directions at https://wiki.postgresql.org/wiki/Apt, is the one I believe you are using.

sudo apt-get install postgresql-9.4-postgis-2.1

Note that

sudo apt-get install postgis

should also work, but I'm not which version of PostGIS it will attempt to install since you are connected to both PostgreSQL and Ubuntu repositories, and the Ubuntu repository is still only up to PostgreSQL 9.3. So there might be a dependency issue there, but I'm not going to attempt to confirm that on my system.

Once this is installed (you can confirm by looking for /usr/share/postgresql/9.4/extension/postgis.control, the file that showed as missing before), you can proceed by logging on to PostgreSQL with a SUPERUSER account, connecting to your database (not the postgres database, your actual data database) and

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
CREATE EXTENSION fuzzystrmatch;
CREATE EXTENSION postgis_tiger_geocoder;

Note that fuzzystrmatch (which is useful for the geocoder) requires the postgresql-contrib package.

I'm glossing over a lot here, but it's possible that I haven't correctly identified the problem, so I don't want to expand on this until I know we're on the right track. Also, please refer to my blog post above for more detail.

Related Question