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 http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm

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
wget http://grass.osgeo.org/grass64/source/grass-6.4.1RC1.tar.gz
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:

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.

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 http://packages.atrpms.net/RPM-GPG-KEY.atrpms
sudo rpm -Uhv http://dl.atrpms.net/el6-x86_64/atrpms/stable/atrpms-repo-6-4.el6.x86_64.rpm

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.

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/libgdal.so ..

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:

cat  /etc/ld.so.conf.d/qgis.conf
      /usr/local/grass-6.4.1RC1/lib
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

16 thoughts on “GIS on Scientific Linux 6

  1. 3/29/2011

    Great Job! Exactly what I needed! You saved me days of work since I am a bit rusty on my Linux.

    I haven’t played with Linux in 15 years and decided to start again. I decided I wanted to start again and explore GIS applications with weather products and web delivery, so I installed SL6 in a VMware VM on Windows 7, works great so far.

    Next was GRASS. I must say your tutorial is quite thurough! Since I only installed a basic Destop of SL6 with minimal customization the only problem I ran into getting GRASS installed was that it was missing the development portions.
    In particular:

    LIBJPEG
    OPENGL
    TCL/TK
    FFTW
    Wx-Widgets

    I installed these through the Add/Remove software tool. Once these were installed GRASS compiled without a hitch! It also runs great from my initial start up.

    Next I tackled the Qt section and ran into problems on the compile. However, I noticed the same version was in the SL6 Add/Remove software package and I installed from there.

    Finally I tried your instructions on installing QGIS. The downloads worked fine, but I got complaints from CMAKE that the variables below needed to be defined. I finally found them in the CMakeCache.txt file and assigned the recommended path as such:

    //Path to a file.
    QWT_INCLUDE_DIR:PATH=~/Downloads/qgis_trunk/src/app

    //Path to a library.
    QWT_LIBRARY:FILEPATH=~/Downloads/qgis_trunk/src/app

    CMake ran fine I think as I didn’t see an error on my return from the shower.

    When I got to make, that is when things went wrong.
    Tons of No such file or directory errors!

    Sample Below

    [root@SL6 build]# make
    [ 0%] Built target svnversion
    [ 7%] Built target ui
    [ 24%] Built target qgis_core
    [ 34%] Built target qgis_gui
    [ 36%] Built target qgis_analysis
    [ 36%] Building CXX object src/app/CMakeFiles/qgis.dir/qgisapp.cpp.o
    In file included from ~/Downloads/qgis_trunk/src/app/qgisapp.cpp:121:
    ~/Downloads/qgis_trunk/src/app/gps/qgsgpsinformationwidget.h:26:28: error: qwt_plot_curve.h: No such file or directory
    In file included from ~/Downloads/qgis_trunk/src/app/gps/qgsgpsinformationwidget.h:27,
    from ~/Downloads/qgis_trunk/src/app/qgisapp.cpp:121:
    ~/Downloads/qgis_trunk/src/app/gps/qwtpolar/qwt_polar_plot.h:14:33: error: qwt_double_interval.h: No such file or directory
    ~/Downloads/qgis_trunk/src/app/gps/qwtpolar/qwt_polar_plot.h:15:27: error: qwt_scale_map.h: No such file or directory

    and many more !!!

    Well I got tired so off to dream land I go. I accomplished my main goal of getting GRASS installed, but thought I’d check out QGIS while I was at it. Maybe I’ll wait for the RPM package on that one!

    Anyway Thanks a bunch!

    CaWxMan

  2. Hi CaWxMan:
    Thanks for the encouraging reply. And welcome back to Linux.

    On my build the QTW_LIBRARY looks like this:
    QWT_INCLUDE_DIR:PATH=/usr/include/qwt
    QWT_LIBRARY:FILEPATH=/usr/lib64/libqwt.so.

    Check that you have installed the two rpm packages qwt and qwt-devel (from EPEL). The cmake script should find these includes by itself…
    After running the cmake -L .. command, scan thru the output and make sure everything is found correctly (no blanks or “Not Found” warnings).

    Cheers,
    Micha

  3. Hi Micha,
    I want to get into using GRASS with R (I already use R, been a long time since I looked at GRASS) – so this is right on the money, thankyou. R (and GRASS, as far as I understand) can be run without their graphical front ends – and this is what I’d like to do (eventually in a VirtualBox – with outputs written to host folders shared between the virtual machine and the host)… To achieve a separation between the (routine satellite data) numerical processing and display. Do you know if GRASS can be built without the (display) graphics components? I currently have a basic SL6 installation without a graphics desktop (just enough X to deliver an X display to another machine via ssh -X). Jim.

  4. James E Davies :

    Hi Micha,
    Do you know if GRASS can be built without the (display) graphics components? I currently have a basic SL6 installation without a graphics desktop (just enough X to deliver an X display to another machine via ssh -X). Jim.

    Hi Jim:
    GRASS can certainly be run without the GUI:
    $ grass -text
    To build without any graphics components try:
    $ ./configure –without-x

    Also be aware that if you want the GRASS data ($GISDBASE) to be on some shared drive you must be the owner of that directory.

  5. Hi Micha, Don’t want to fill up your blog with gratitude, but I gotta say thanks. Jim.

  6. It seemed a few years (okay, a decade) ago as if Linux was going to make a run at WIndows, but although it’s probably more popular overall now than it was then, it doesn’t seem to have the growth or momentum that will have it vying for the top OS spot anytime soon.

  7. After being a Windows believer ever since I got my first computer, it’s just now that I switched servers. Linux provides the necessary services and components required from a mega server. You may think that switching from Windows to Linux is a difficult task but try upgrading from Windows XP to Windows 7 and you’ll know what real “difficult” is.

  8. Hi Micha :-)

    Thanks for this post. Are there any up-to-date instructions?

    I get some error when trying to install grass from the repository (details below). I would like to avoid building it by myself since I intend to show how to set up a GIS workstation just by using the ELGIS repository.

    Who is maintaining this repo? i.e., who will update the grass package?
    All the best, Nikos

    ps- error while trying to “yum install grass”:

    —%%—

  9. Nikos Alexandris :

    Hi Micha :-)

    Thanks for this post. Are there any up-to-date instructions?

    I get some error when trying to install grass from the repository (details below). I would like to avoid building it by myself since I intend to show how to set up a GIS workstation just by using the ELGIS repository.

    Who is maintaining this repo? i.e., who will update the grass package?
    All the best, Nikos

    ps- error while trying to “yum install grass”:

    —%%—

    Hi Nikos:
    Thanks for your interest. The elgis repo has an updated package for GRASS, 6.4.2 instead of 6.4.1, in the testing repo. AFAIK they are now moving the testing packages (included gdal 1.8.1, and a more recent geos) into the regular repo since they have been tested “long enough”. If you can’t install GRASS from the repo, then certainly post to their list:
    http://lists.osgeo.org/mailman/listinfo/el
    Maybe there’s some mismatch during this migration?
    Regards,
    Micha

  10. Micha Silver :


    ps- error while trying to “yum install grass”:
    —%%—

    Hi Nikos:
    Thanks for your interest. The elgis repo has an updated package for GRASS, 6.4.2 instead of 6.4.1, in the testing repo. AFAIK they are now moving the testing packages (included gdal 1.8.1, and a more recent geos) into the regular repo since they have been tested “long enough”. If you can’t install GRASS from the repo, then certainly post to their list:
    http://lists.osgeo.org/mailman/listinfo/el
    Maybe there’s some mismatch during this migration?
    Regards,
    Micha

    O-kay, I found the answer at: .
    Regards, Nikos

  11. O-kay, I found the answer at: .
    Regards, Nikos

    Hi Nikos:
    How about posting some details, either on the elgis maillist, or here?
    Thanks,
    Micha

  12. Sure,

    (but I think it’s solved in the link I provided, pointing to a relevant post in the , in the previous post is not visible!?)

    # installing grass
    yum install grass

    # the last part of the output
    The error was :

    –%%–

    The answer(s) is(are) in the list already!
    Best, Nikos

  13. Sorry for typos!!

    Again: it’s solved in the link I provided in a previous post, pointing to a relevant thread in the el at osgeo mailing list.
    Check here
    Nikos

    ps- Is it my fault that links posted here are filtered out?

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>