Quantcast
Channel: David Ghedini
Viewing all articles
Browse latest Browse all 21

PostGIS 2.0 on CentOS

$
0
0
Refractions released PostGIS 2.0 in April.

You can see details here: http://postgis.refractions.net/news/20120403/
Devrim Gunduz has made the PostGIS 2.0 packages available
You can download the repo rpms here
If you are using the pg repos, installation of PostGIS has gone from trivial to, well... whatever is less than trivial.

Step 1. Install Prequisites



Of course, you will need to have PostgreSQL installed.
On centOS, the required GDAL is not available via CentOS repo, so you can use EPEL.

You can view the EPEL repos here
Download and install the repo:
wget http://ftp.linux.org.tr/epel/6/i386/epel-release-6-6.noarch.rpm
rpm -i epel-release-6-6.noarch.rpm

Issue yum list gdal* to view GDAL packages and install
yum list gdal*
yum install gdal gdal-devel [gdal-java gdal-perl gdal-python]


Step 2. Install PostGIS 2.0



With the PostgreSQL repo installed, you can now install either PostGIS 1.5 or 2.0

For PostGIS 2.0, the name is 'postgis2_91'

yum list postgis*
yum install postgis2_91 postgis2_91-devel [postgis2_91-docs postgis2_91-utils]



Step 3. Install PostGIS on target database as user postgres



With PostGIS 2.0, you can install using CREATE EXTENSION

Simply connect to the target database as postgres and issue 'CREATE EXTENSION postgis_topology' and 'CREATE EXTENSION postgis_topology'

For Example:
Database Name: mydb
Database Owner: myuser


-bash-4.1$ psql
Password:
psql (9.1.3)
Type "help" for help.

postgres=# \c mydb postgres
You are now connected to database "mydb" as user "postgres".
mydb=# CREATE EXTENSION postgis;
CREATE EXTENSION
mydb=# CREATE EXTENSION postgis_topology;
CREATE EXTENSION



Step 4. Change ownership of the spatial_ref_sys table to the DB owner:



You can now change ownership of the spatial_ref_sys table to the DB owner (if applicable):


mydb=# \dt
              List of relations
 Schema |      Name       | Type  |  Owner
--------+-----------------+-------+----------
 public | spatial_ref_sys | table | postgres
(1 row)

mydb=# alter table spatial_ref_sys owner to myuser;
ALTER TABLE



Check if ownership is updated:

mydb=# \dt
              List of relations
 Schema |      Name       | Type  |  Owner
--------+-----------------+-------+----------
 public | spatial_ref_sys | table | myuser
(1 row)

mydb=# 



Viewing all articles
Browse latest Browse all 21

Trending Articles