Wednesday, May 14, 2008

Installing Postgis

Install postgresql before proceeding with the below given info.

1) Download postgis,geos,proj4.
a) http://www.remotesensing.org/proj
b) http://geos.refractions.net
c) http://postgis.refractions.net/download/


2) Extract all of them and do a cd to proj4


3) cd proj4
$ ./configure
$ make
$ sudo make install

4) cd geos

$ ./configure
$ make
$ sudo make install

5) cd postgis

$ ./configure --with-pgsql=/usr/local/pgsql/bin/pg_config
$ make
$ sudo make install

6) set the path

$ vim /etc/profile
#add the followig lines

LD_LIBRARY_PATH=/usr/local/pgsql/lib
export LD_LIBRARY_PATH

PG_HOME=/usr/local/pgsql
PATH=/usr/local/lib:$PG_HOME/bin:$PG_HOME/lib:$PATH

7) Edit vim /etc/ld.so.conf

# add the following lines

/usr/local/pgsql/lib
/usr/local/lib

# run ldconfig
$ldconfig

8) Creating spatial data

> su - postgres
password: **************

> createlang plpgsql databasename
> psql -f lwpostgis.sql -d your_database
> psql -f spatial_ref_sys.sql -d your_database