V.krige GSoC 2009

From GRASS-Wiki
Revision as of 21:21, 30 September 2015 by ⚠️Pvb (talk | contribs) (→‎Installation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

v.krige: Python porting and wxGUI addition

Anne Ghisla's Google Summer of Code 2009 project, mentored by Martin Landa and Michael Barton

Aim of the project

As GRASS presently lacks kriging capability, it is performed via an add-on, v.autokrige, that delegates analysis to R (package automap). This module is written in ksh and has the classical autogenerated GUI. The project aims to rewrite the module in Python, creating a new GUI in wxPython that allows the user to refine parameters. I therefore plan to examinate present v.autokrige code and port it into Python, possibly improving it at the same time, and add a wxPython GUI. All time left will be dedicated to addition of further functionality, in respect of the most needed.

State of the art

V.krige is back to functionality in GRASS 7 trunk, from r57146 - made during GRASS_Community_Sprint_Prague_2013 Soon more improvements and fixes will be available, and also be backported to GRASS 6.5. Until then, feel free to comment on the tickets on Trac and on grass-dev mailing list.



Dependency check is performed on grass-python module, R, rpy2 and R packages gstat and rgrass7. If something is missing, the module won't start. Some graceful popup window will be set up in the near future. At the moment it aborts with a message in the shell.

Kriging relies on R package gstat, the most widespread. geoR tab is now hidden as it doesn't provide any functionality, but if anyone is interested in using it instead of gstat I'll put this todo higher in the list.

The list of point layers is provided by VectorSelect class (gselect module) to provide uniformity of layout with wxGUI. The filtering is done once at the start of the module, then if the user adds a suitable point layer she/he will press the Refresh button to force addition to the list. Automatic refresh on popup has been tested as too time and resource consuming.

Installation

For GRASS 6.5 <r40048, it is easy to install it via g.extension (for GRASS 6.4 it is an AddOn, from 6.5+/7 onwards included). Simply type in a GRASS shell:

g.extension v.krige

To install v.krige.py from source, please refer to Compile_and_Install#Scripts. Source is available on SVN:

svn co https://svn.osgeo.org/grass/grass-addons/vector/v.krige

The module requires GRASS >= 6.4 RC5 - it uses the new version of grass-python library. At the moment, no backward compatibility with previous versions is provided.

The module has dependencies:

  • R 2.x - no exhaustive tests on compatible versions. An up-to-date R package will do the job in 99% cases.
  • R packages spgrass6 (for GRASS 6.*) or rgrass7 (for GRASS 7.*), gstat and maptools
  • Python module rpy2

Be sure that ALL these dependencies are installed and operative. See below for platform-specific details.

Notes for Debian GNU/Linux

Install the dependiencies:

aptitude install R python-rpy2

Attention! python-rpy IS NOT SUITABLE.

To install R packages, use either R's function (as root):

install.packages("gstat", dep=T)
install.packages("spgrass6", dep=T)
install.packages("maptools", dep=T)

If you are running GRASS 7.*, install rgrass7 instead of spgrass6:

install.packages("rgrass7", dep=T)

Alternatively, you can install the packages using the brand new Debian packages [6]. To do so, add to repositories' list for 32bit:

deb http://debian.cran.r-project.org/cran2deb/debian-i386 testing/

or, for 64bit:

deb http://debian.cran.r-project.org/cran2deb/debian-amd64 testing/

and get the packages via

aptitude install r-cran-gstat r-cran-spgrass6 maptools

if you are using GRASS 6.*, or

aptitude install r-cran-gstat r-cran-rgrass7 maptools

if you are using GRASS 7.*

Notes for Windows

At this very moment, no backward compatibility with OSGeo4W's packaged GRASS 6.4svn2 is provided, nor with WinGRASS. Testing is planned, as latest WinGRASS includes the most recent python library.

If you really need to run v.krige right now on Windows, I suggest to compile GRASS following this guide. You could also use Linux in a virtual machine. Or install Linux in a separate partition of the HD. This is not as painful as it appears, there are lots of guides over the Internet to help you.

Documentation

Notes on v.krige usage, examples and tips are available in the module's help page, available via Help button if the GUI.

Kriging theory is available in Isaaks and Srivastava's "An Introduction to Applied Geostatistics" [1]. Another great book.

Developers documentation is available at Trac's wiki http://trac.osgeo.org/grass/wiki/wxGUIDevelopment/vkrige .

Users feedback and other kriging software

  • Call for users has been done on gfoss.it, grass-it and grass-users, r-sig-geo and r-sig-ecology mailing lists. Thanks to Giovanni Manghi and João Tiago from GFOSS.pt and Giovanni Allegri for user advices, and to Edzer Pebesma, Paul Hiemstra, Ebrahim Jahanshiri, Dylan Beaudette for support on R side.
  • There are (have been) some GRASS modules that perform kriging, like:
    • v.surf.krige, v.variogram: no longer developed by authors, difficult to port.
    • s.surf.krig: deprecated since GRASS 6 series.
    • scripts including R and spgrass6: are the concrete basis upon which build the module.
  • Obtained ArcGIS availability for comparison of interface and functionality, because it is AFAIK the widespread tool used for kriging. Also Isats [2] is a valuable source of ispiration for interface design.

Planned Timeline

Draft and definitive:

  • create a wxPython interface for ordinary kriging. Will follow Humane Interface rules [3].
  • integrate R package automap
  • midterm deadline: have a working module that performs ordinary kriging.
  • integrate more R functions from gstat and geoR, giving the user the choice between gstat and geoR (kriging results vary in respect of implementation)


References