Home |  MySQL Buzz |  FAQ |  Feeds |  Submit your blog feed |  Feedback |  Archive |  Aggregate feed RSS 2.0 English Deutsch Español Français Italiano 日本語 Русский Português 中文
Install PostGIS 9.2 on RedHat 6.2
+0 Vote Up -0 Vote Down

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. Use the pgdg-centos92 package for CentOS and the pgdg-redhat92 package for Redhat.

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

NOTE: Redhat User’s only - I found Redhat repositories (6 and epel) do supply gdal-1.7 but it is compiled to be used with the UNIX ‘libodbc’ package that are not provided.  (I have no idea why.)  Because of this you will need to download the gdal-1.8 CentOS file.   This does not apply to CentOS user’s because the correct package is supplied.  (Go figure.)

 $ wget http://yum.opengeo.org/centos/6/x86_64/gdal-1.8.1-1.el6.x86_64.rpm
$ rpm -i gdal-1.8.1-1.el6.x86_64 --nodeps

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.  So, you need to put in YOUR network address and netmask.

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

host    all             all             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
postgres=# \c template1
postgres=# create extension postgis;

Now you can create a GIS database for your data.

 $ createdb geodata -T template1

OR from psql you can create the extension and grant access to the GEO functions.

 postgres=# create database geodata;
postgres=# \c geodata
postgres=# create extension postgis;
postgres=# grant all on spatial_ref_sys to "postgres";
postgres=# grant all on geometry_columns to "postgres";

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 --------------

You may find it

How to use GIS functions.



Some interesting GIS data.






You must be logged in with a MySQL account to vote on Planet MySQL entries. More information on PlanetMySQL voting.

Planet MySQL © 1995, 2014, Oracle Corporation and/or its affiliates   Legal Policies | Your Privacy Rights | Terms of Use

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.