Install PostGIS 9.2 on RedHat 6.2

September 13, 2012

First you need to be able to resolve a few dependencies so you’ll need the epel repository.

 $ wget http://mirror.chpc.utah.edu/pub/epel/6/i386/epel-release-6-7.noarch.rpm

Now you can add the PostgreSQL repository to your system.

 $ wget http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-5.noarch.rpm

To use GIS functions you’ll need three packages.

 $ yum install postgresql92
 $ yum install postgresql92-server
 $ yum install postgis2_92

You need to initialize (create) the default databases files before you start postgres.

 $  /etc/init.d/postgresql-9.2 initdb

If you are going to connect to the servers from a workstation on your network you’ll need to let Postgres access all your network controllers (NICs).

 $ vi /var/lib/pgsql/9.2/data/postgresql.conf

listen_addresses = ‘*’

And, you’ll need to tell Postgres from where and how users will connect.

$ vi /var/lib/pgsql/9.2/data/pg_hba.conf

host    all             all             192.168.2.0/24          md5

Now you can start Postgres.

 $  /etc/init.d/postgresql-9.2 start

To use GIS functions you’ll need to add the postgis extension to your database. Most people create new databases from an existing template.  Change to (use) template1 before you added the extension to it.

 $ su - postgres
 $ psql
 postgres=# \c template1
 template1=# create extension postgis;

Now you can create a GIS database for your data.

 $ createdb geodata -T template1

OR

 postgres=# create database geodata;
 postgres=# \c geodata
 postgres=# create extension postgis;

Here are the steps to download and load the Oklahoma county shapes into the database we created.

 $ wget http://geo.ou.edu/oeb/Statewide/COUNTY.zip
 $ unzip COUNTRY.zip
 $ shp2pgsql county.shp  > county.sql
 $ psql geodata -f county.sql

Now lets try it.  What county is at this point on the earth?

$ psql geodata
 geodata=# select name from county where ST_Contains(geom, ST_GeomFromText('POINT(-97.0 35.0)'));
name
 --------------
 POTTAWATOMIE
 (1 row)

 

How to use GIS functions.

http://postgis.refractions.net/docs/using_postgis_dbmanagement.html#id590441

 

Some interesting GIS data.

http://geo.ou.edu/DataFrame.htm
http://downloads.cloudmade.com/

 


Tweet

posted in Commentary by mark

Follow comments via the RSS Feed | Leave a comment | Trackback URL

1 Comment to "Install PostGIS 9.2 on RedHat 6.2"

  1. Log Buffer #286, A Carnival of the Vanities for DBAs | The Pythian Blog wrote:

    [...] fine step by step blog by Mark Grennan about installing PostGIS 9.2 on RedHat 6.2 [...]

Leave Your Comment

 



Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org
Creative Commons License
MySQL Fan Boy by Mark Grennan is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.
HOME