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:

sudo rpm -Uvh

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 we’ll get the basic spatial stuff, development tools, the python GUI packages and databases for GIS. These are all dependancies for compiling GRASS GIS.

sudo yum install geos proj proj-epsg gdal proj-devel geos-devel gdal-devel
sudo yum install gcc gcc-c++ gcc-gfortran flex byacc ncurses-devel bison pkgconfig
sudo yum install wxPython wxPython-devel wxGTK wxGTK-devel swig python-psycopg2 numpy PyQt4 PyQt4-devel sip sip-devel
sudo yum install mesa-libGLU-devel mesa-libGLw-devel libXmu-devel lesstif lesstif-devel libjpeg-devel
sudo yum install tcl tcl-devel tk tk-devel fftw2 fftw2-devel hdf5
sudo yum install unixODBC postgresql-devel mysql-devel sqlite-devel freetype-devel

With that behind us, pull into the OSGeo website to get the source code for GRASS

cd ~/Downloads
tar xvzf grass-6.4.1RC1.tar.gz
cd grass-6.4.1RC1

I’ve unzipped the source, and dropped into that directory. Here’s my configure line. Pretty straightforward except for the special location of the freetype2 fonts include dir.

./configure --prefix=/usr/local \
      --with-cxx --enable-64bit \
      --enable-largefile --with-x \
      --with-freetype --with-freetype-includes=/usr/include/freetype2 \
      --with-geos --with-wxwidgets --with-postgres \
      --with-python --with-sqlite --with-proj-share=/usr/share/proj

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:

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

sudo yum install cmake gsl gsl-devel expat expat-devel qwt qwt-devel PyQwt PyQwt-devel fcgi fcgi-devel

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:

sudo rpm --import
sudo rpm -Uhv

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

mkdir build
cd build
cmake -L -DGRASS_PREFIX:PATH=/usr/local/grass-6.4.1RC1 \
      -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/qgis-1.7 \
      -DGDAL_LIBRARY:STRING=/usr/lib64/ ..

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.

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 and run ldconfig. I usually add a new qgis.conf file which contains:

cat  /etc/
sudo ldconfig

OK, buckle up and try /usr/local/qgis-1.7/bin/qgis & and you should be zooming off to do some geography, leaving me and my post in the dust.

Update (5-Nov-2012):
More details have been posted on the ELGIS maillist. Check here

Leave a Reply

Your email address will not be published. Required fields are marked *