Tuesday, 26 September 2017

Installing postgis on postgresql 9.1 not working



I'm trying to install Postgis 2.0 on a perfectly functionig postgresql 9.1.10 database.


I installed the package via:


richard@srv1:/$ sudo apt-get install postgresql-9.1-postgis postgis
Reading package lists... Done
Building dependency tree
Reading state information... Done
postgis is already the newest version.
postgresql-9.1-postgis is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.


With out any errors. Then I try to add postgis as an extension to an existing (empty) database, with:


 dev=# CREATE EXTENSION postgis;
ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/postgis.control": No such file or directory

If I look at the location the file does not exist.


What am I missing? I can't figure it out. If I google I only get ancient results....


Where can I find the version of the installed postgis? As I'm not able to do a SELECT PostGIS_version();


Environment: Postgresql 9.1.10, Ubuntu 12.04


Update


I'm willing to install postgis2.0; apparently I have 1.5 installed. After purging that version I added the repository



deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main

After trying to install the package via


sudo apt-get update
sudo apt-get install postgis

it ends with:


Errors were encountered while processing:
/var/cache/apt/archives/libgdal1_1.9.0-3.1~pgdg12.4+1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)


Update 2


It appears because of the naming of the packages, it installed the wrong architecture type package. But I ended up using this website and these steps after making sure I had gdal>= 1.9.0 and GEOS >=3.3.3:


wget http://postgis.refractions.net/download/postgis-2.0.0.tar.gz
tar xfvz postgis-2.0.0.tar.gz
cd postgis-2.0.0
./configure --with-gui

make
sudo make install

sudo ldconfig
sudo make comments-install


sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/shp2pgsql
sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pgsql2shp
sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/raster2pgsql

TADA


durham=#  select PostGIS_full_version();

NOTICE: Function postgis_topology_scripts_installed() not found. Is topology support enabled and topology.sql installed?
postgis_full_version
--------------------------------------------------------------------------------------------------------------------------------------------------------------
POSTGIS="2.0.0 r9605" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.9.1, released 2012/05/15" LIBXML="2.7.8" LIBJSON="UNKNOWN" RASTER
(1 row)

Answer



By default, you don't have PostGIS 2.0 but 1.5 (see http://packages.ubuntu.com/fr/precise/postgresql-9.1-postgis)


By doing CREATE EXTENSION postgis; you're trying to initialize from PostgreSQL with the new loading mechanism a PostGIS version (1.5) that do not support it and in this case, you will need to follow the PostGIS 1.5 official doc


If you need 2.0, follow various instructions already available in previous gis.stack.exchange.com answers e.g Install PostGIS on Ubuntu 12.04 or Can POSTGIS 2.0 be install with POSTGRES 9.2 on Ubuntu 12.04 OS at the moment?


Edit due to changes in question:



When I look in the repository (http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main), I see you can get different PostGIS versions for different PostgreSQL versions, so sudo apt-get install postgis is not enough clear for the package manager


Did you try?


sudo apt-get install postgresql-9.1-postgis-2.0

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...