GIS on Scientific Linux 6

Exciting days these for open source GIS users. Debian 6 “Squeeze” is now the stable release, with full support for everything spatial. In the “rpm” camp, since Red Hat’s release of RHEL6 we’re looking forward to an equivalent selection of ready-to-go GIS software. The Fedora folks have been racing around the track to push out updated packages for each new Fedora release.
Developers of CentOS, the popular Red Hat clone, chose to give priority to security updates for the current CentOS 5.5 (a wise decision in my view). Although I’m sure that CentOS 6 is just a stone’s throw down the road. Meanwhile Scientific Linux has inched ahead with their version 6. Those looking to drive an enterprise class GIS workstation can choose the turn by turn steps below to setup GRASS GIS and Quantum GIS on SL 6.0.
So ladies and gents, rev up your engines and let’s get rolling.
I’m beginning with a fresh installation of SL 6.0 64 bit. As always, much of the software, libraries and tools are directly installable thru yum. We begin by adding the EPEL (Extra Packages for Enterprise Linux) repository. This is done simply by:

Since I’m running the 64 bit version of Scientific Linux, throughout this post I point to 64 bit packages. If you’re on a 32 platform, change the links appropriately. In addition, I’ve setup my sudoers so that I can run commands requiring root privileges with sudo.

Now run make && sudo make install
and your GRASS binary is ready to go as /usr/local/bin/grass64.

Need to maneuver thru some spatial statistical analyses? Get R and the spatial packages. So far there are ready built rpms for only some basic R packages. But we can get whatever else we need with R’s own package installer.
Use yum to get the core R package as well as the xml2 parser.sudo yum install R-core R-devel libxml2 libxml2-devel
Now start the R interface and do:
R
>install.packages(c("sp", "spgrass6", "rgdal", "spatial", "gstat", "spdep", "spatstat"));
and R is assembled, and prepared for action.

We’re now approaching the QGIS junction. First some dependencies, notably the cmake infrastructure and Qt4, etc.

All recent versions of QGIS require several Qt libraries, one of which – QTWebkit – is not yet available from the EPEL repo. Instead we’ll spin by ATrpms for this. You can choose to install the ATrpms repo as follows:

However on the CentOS site and in other places there are warnings not to mix repositories. I suggest, if you do install the repo, to set it disabled (by setting enabled=0 in /etc/yum.repo.d/atrpms.repo). Then when you do want a specific package from ATrpms, you’ll need to add the --enablerepo=atrpms flag to the yum command.
In our case, since we’ll need only two packages, you might skip installing the repo altogether, and just pull down these two rpms and install them as follows:
cd ~/Downloads
wget http://dl.atrpms.net/all/qtwebkit-2.0-3.el6.x86_64.rpm
wget http://dl.atrpms.net/all/qtwebkit-devel-2.0-3.el6.x86_64.rpm
sudo rpm -Uhv qtwebkit-*

Next steer over to the QGIS download page to get the latest version. As I write this, QGIS 1.7 is going into “feature freeze” meaning that it will very soon be the official stable release. So that’s what we want. (First install subversion and use svn to get the most recent source tree).
sudo yum install svn
svn co https://svn.osgeo.org/qgis/trunk/qgis qgis_trunk
cd qgis_trunk

Building QGIS requires the preparatory step of creating and configuring the source with cmake. I make a “build” directory, drop into that new dir, and run cmake from there. Here’s how it’s done.

Note that I tuned my cmake command with three parameters (the -D… options). First I pointed to the installation of GRASS so that the GRASS plugin will be available. Next I set a prefix (this installation won’t be overwritten by future versions) and finally, the cmake script did not correctly locate the gdal libs since they are under /usr/lib64 on a 64 bit system. The above corrected that. And don’t overlook the ‘..’ at the end of the command.

And we’re ready to step on the gas and start the compile.

make
sudo make install

QGIS needs to find the GRASS libraries in order to load the plugin. So we need to add the path to the GRASS lib directory to ld.so.conf and run ldconfig. I usually add a new qgis.conf file which contains: