[GRASS-SVN] r40045 - in grass/trunk: gui/wxpython
gui/wxpython/gui_modules gui/wxpython/support
gui/wxpython/xml scripts scripts/v.krige
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 18 10:04:47 EST 2009
Author: martinl
Date: 2009-12-18 10:04:47 -0500 (Fri, 18 Dec 2009)
New Revision: 40045
Added:
grass/trunk/scripts/v.krige/
grass/trunk/scripts/v.krige/v.krige.html
Removed:
grass/trunk/scripts/v.krige/description.html
Modified:
grass/trunk/gui/wxpython/gui_modules/goutput.py
grass/trunk/gui/wxpython/support/update_menudata.py
grass/trunk/gui/wxpython/wxgui.py
grass/trunk/gui/wxpython/xml/menudata.xml
grass/trunk/scripts/Makefile
grass/trunk/scripts/v.krige/Makefile
grass/trunk/scripts/v.krige/v.krige.py
Log:
v.krige moved from add-ons to trunk (GSoC)
Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py 2009-12-18 14:35:21 UTC (rev 40044)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py 2009-12-18 15:04:47 UTC (rev 40045)
@@ -411,7 +411,7 @@
if os.environ.has_key("GRASS_REGION"):
del os.environ["GRASS_REGION"]
- if len(cmdlist) == 1:
+ if len(cmdlist) == 1 and cmdlist[0] not in ('v.krige'):
import menuform
# process GRASS command without argument
menuform.GUI().ParseCommand(cmdlist, parentframe=self)
Modified: grass/trunk/gui/wxpython/support/update_menudata.py
===================================================================
--- grass/trunk/gui/wxpython/support/update_menudata.py 2009-12-18 14:35:21 UTC (rev 40044)
+++ grass/trunk/gui/wxpython/support/update_menudata.py 2009-12-18 15:04:47 UTC (rev 40045)
@@ -1,4 +1,4 @@
-"""
+"""!
@brief Support script for wxGUI - only for developers needs. Updates
menudata.xml file.
@@ -12,7 +12,7 @@
License (>=v2). Read the file COPYING that comes with GRASS
for details.
-Usage: python update_menudata.py
+Usage: python support/update_menudata.py
@author Martin Landa <landa.martin gmail.com>
"""
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2009-12-18 14:35:21 UTC (rev 40044)
+++ grass/trunk/gui/wxpython/wxgui.py 2009-12-18 15:04:47 UTC (rev 40045)
@@ -454,7 +454,7 @@
if event:
cmd = self.GetMenuCmd(event)
self.goutput.RunCmd(cmd, switchPage=True)
-
+
def OnMenuCmd(self, event, cmd = ''):
"""!Parse command selected from menu"""
if event:
Modified: grass/trunk/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata.xml 2009-12-18 14:35:21 UTC (rev 40044)
+++ grass/trunk/gui/wxpython/xml/menudata.xml 2009-12-18 15:04:47 UTC (rev 40045)
@@ -1584,6 +1584,14 @@
</menuitem>
<separator />
<menuitem>
+ <label>Ordinary or block kriging</label>
+ <help>Performs ordinary or block kriging.</help>
+ <keywords>vector,interpolation,kriging</keywords>
+ <handler>self.RunMenuCmd</handler>
+ <command>v.krige</command>
+ </menuitem>
+ <separator />
+ <menuitem>
<label>Fill NULL cells</label>
<help>Fills no-data areas in raster maps using v.surf.rst splines interpolation</help>
<keywords>raster,elevation,interpolation</keywords>
@@ -2030,7 +2038,7 @@
</menuitem>
<menuitem>
<label>Patch vector maps</label>
- <help>Creates a vector map by combining other vector maps.</help>
+ <help>Creates a new vector map by combining other vector maps.</help>
<keywords>vector,geometry</keywords>
<handler>self.OnMenuCmd</handler>
<command>v.patch</command>
@@ -2735,7 +2743,7 @@
<separator />
<menuitem>
<label>Add columns</label>
- <help>Adds one or more columns to the attribute table connected to a given vector map</help>
+ <help>Adds one or more columns to the attribute table connected to a given vector map.</help>
<keywords>vector,database,attribute table</keywords>
<handler>self.OnMenuCmd</handler>
<command>v.db.addcolumn</command>
Modified: grass/trunk/scripts/Makefile
===================================================================
--- grass/trunk/scripts/Makefile 2009-12-18 14:35:21 UTC (rev 40044)
+++ grass/trunk/scripts/Makefile 2009-12-18 15:04:47 UTC (rev 40045)
@@ -60,7 +60,8 @@
v.rast.stats \
v.report \
v.out.gps \
- v.what.vect
+ v.what.vect \
+ v.krige
# d.vect.thematic \
# d.out.gpsdrive \
Modified: grass/trunk/scripts/v.krige/Makefile
===================================================================
--- grass-addons/vector/v.krige/Makefile 2009-09-18 06:25:02 UTC (rev 39246)
+++ grass/trunk/scripts/v.krige/Makefile 2009-12-18 15:04:47 UTC (rev 40045)
@@ -1,6 +1,6 @@
MODULE_TOPDIR = ../..
-PGM = v.krige.py
+PGM = v.krige
include $(MODULE_TOPDIR)/include/Make/Script.make
Deleted: grass/trunk/scripts/v.krige/description.html
===================================================================
--- grass-addons/vector/v.krige/description.html 2009-09-18 06:25:02 UTC (rev 39246)
+++ grass/trunk/scripts/v.krige/description.html 2009-12-18 15:04:47 UTC (rev 40045)
@@ -1,224 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-<em>v.krige</em> allows to perform kriging operations in GRASS
-environment, using R software functions in background.
-
-<h2>NOTES</h2>
-
-<em>v.krige</em> is just a front-end to R. The options and parameters are the same offered by packages <i>automap</i> and <i>gstat</i>.
-
-<p>
-Kriging, like other interpolation methods, is fully dependent on input
-data features. Exploratory analysis of data is encouraged to find out
-outliers, trends, anisotropies, uneven distributions and consequently
-choose the kriging algorithm that will give the most acceptable
-result. Good knowledge of the dataset is more valuable than hundreds
-of parameters or powerful hardware. See Isaaks and Srivastava's book,
-exhaustive and clear even if a bit outdated.
-
-<h3>Dependencies</h3>
-
-<dl>
-<dt><b>GRASS 6.5 with wxPython support</b></dt>
-<dd></dd>
-
-<dt><b>R software >= 2.x</b></dt>
-<dd></dd>
-
-<dt><b>rpy2</b></dt>
-<dd>Python binding to R. Note! rpy is not supported.</dd>
-
-<dt><b>R packages automap and gstat. </b></dt>
-<dd>automap is optional (provides automatic variogram fit).</dd>
-</dl>
-
-<h3>Install</h3>
-
-<h4>Easy way: g.extension</h4>
-
-Simply run:
-
-<div class="code"><pre>
- g.extension v.krige
-<pre></div>
-
-<h4>Less easy way: manual install</h4>
-
-It is sufficient to copy it into the (GRASS binaries) path
-somewhere. Alternatively, install addons into a separate GRASS addons
-binaries/scripts directory which is easier to maintain. It avoids
-getting clobbered every time you reinstall GRASS. To use these
-separately stored scripts, set and export the GRASS_ADDON_PATH
-environment variable before starting GRASS and it will automatically
-be added to the module search path. To simplify this, do for example:
-
-<div class="code"><pre>
- # add in $HOME/.bashrc:
- GRASS_ADDON_PATH=/usr/local/grass/addons/
- export GRASS_ADDON_PATH
-<pre></div>
-
-Make sure that the script is executable, then just call it in GRASS
-typing the filename. Python scripts need to be called writing the
-extension as well, like:
-
-<div class="code"><pre>
- GRASS 6.5.svn (spearfish60):~ > v.krige.py
-<pre></div>
-
-<h4>Notes for Debian GNU/Linux</h4>
-
-
-Install the dependiencies. <b>Attention! python-rpy IS NOT
-SUITABLE.</b>:
-
-<div class="code"><pre>
- aptitude install R python-rpy2
-<pre></div>
-
-To install R packages, use either R's function (as root):
-
-<div class="code"><pre>
- install.packages("gstat", dep=T)
- install.packages("spgrass6", dep=T)
-<pre></div>
-
-either the brand new Debian packages [5], add to repositories' list
-for 32bit or 64bit (pick up the suitable line):
-
-<div class="code"><pre>
- deb <a href="http://debian.cran.r-project.org/cran2deb/debian-i386">http://debian.cran.r-project.org/cran2deb/debian-i386</a> testing/
- deb <a href="http://debian.cran.r-project.org/cran2deb/debian-amd64">http://debian.cran.r-project.org/cran2deb/debian-amd64</a> testing/
-<pre></div>
-
-and get the packages via aptitude:
-
-<div class="code"><pre>
- aptitude install r-cran-gstat r-cran-spgrass6
-<pre></div>
-
-<h4>Notes for Windows</h4>
-
-At this very moment, v.krige is developed against GRASS 6.5
-(6_develbranch) and no backward compatibility with OSGeo4W's packaged
-GRASS 6.4svn2 is provided, nor with WinGRASS.
-
-<p>
-If you really need to run v.krige right now on Windows, I suggest to
-compile GRASS following this
-<a href="http://trac.osgeo.org/grass/wiki/CompileOnWindows">guide</a>.
-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.
-
-
-<h3>Computation time issues</h3>
-
-Please note that kriging calculation is slown down both by high number
-of input data points and/or high region resolution, even if they both
-contribute to a better output.
-
-<h2>EXAMPLES</h2>
-
-Kriging example based on elevation map (Spearfish data set).
-
-<p>
-<b>Part 1: random sampling</b> of 2000 vector points from known
-elevation map. Each point will receive the elevation value from the
-elevation raster, as if it came from a point survey.
-
-<div class="code"><pre>
- g.region rast=elevation.10m -p
- v.random output=rand2k_elev n=2000
- v.db.addtable map=rand2k_elev column="elevation double precision"
- v.what.rast vect=rand2k_elev rast=elevation.10m column=elevation
-<pre></div>
-
-<p>
-<b>Part 2: remove points lacking elevation attributes</b>. Points
-sampled at the border of the elevation map didn't receive any
-value. v.krige has no preferred action to cope with no data values, so
-the user must check for them and decide what to do (remove points,
-fill with the value of the nearest point, fill with the global/local
-mean...). In the following line of code, points with no data are
-removed from the map.
-
-<div class="code"><pre>
- v.extract rand2k_elev output=rand2k_elev_filt where="elevation not NULL"
-<pre></div>
-
-Check the result of previous line ("number of NULL attributes" must be
-0):
-
-<div class="code"><pre>
- v.univar rand2k_elev_filt type=point column=elevation
-<pre></div>
-
-<p>
-<b>Part 3: reconstruct DEM through kriging</b>. Using automatic
-variogram fit is the simplest way to run v.krige from CLI (note:
-requires R's automap package). Output map name is optional, the
-modules creates it automatically appending "_kriging" the the input
-map name and also checks for overwrite. If output_var is specified,
-the variance map is also created. Automatic variogram fit is provided
-by R package automap, the variogram models tested by the fitting
-functions are: exponential, spherical, Gaussian, Matern, M.Stein's
-parametrisation. A wider range of models is available from gstat
-package and can be tested on the GUI via the variogram plotting. If
-model is specified in the CLI, also sill, nugget and range values are
-to be provided, otherwise an error is raised (see second example of
-v.krige command).
-
-<div class="code"><pre>
- v.krige.py input=rand2k_elev_filt column=elevation output=rand2k_elev_kriging \
- output_var=rand2k_elev_kriging_var
- v.krige.py input=rand2k_elev_filt column=elevation output=rand2k_elev_kriging \
- output_var=rand2k_elev_kriging_var model=Lin sill=2500 nugget=0 range=1000 \
- --overwrite
-<pre></div>
-
-Or run wxGUI, to interactively fit the variogram and explore options:
-
-<div class="code"><pre>
- v.krige.py
-</pre></div>
-
-<b>Calculate prediction error</b>:
-
-<div class="code"><pre>
- r.mapcalc "rand2k_elev_kriging_pe = sqrt(rand2k_elev_kriging_var)"
- r.univar elevation.10m
- r.univar rand2k_elev_kriging
- r.univar rand2k_elev_kriging_pe
-<pre></div>
-
-The results show high errors, as the kriging techniques (ordinary and
-block kriging) are unable to handle a dataset with a trend, like the
-one used in this example: elevation is higher in the southwest corner
-and lower on northeast corner. Universal kriging can give far better
-results in these cases as it can handle the trend. It is available in
-R package gstat and will be part of a future v.krige release.
-
-<h2>SEE ALSO</h2>
-
-
-R package <a href="http://cran.r-project.org/web/packages/gstat/index.html">gstat</a>,
-mantained by Edzer J. Pebesma and others
-<br>
-R
-package <a href="http://cran.r-project.org/web/packages/spgrass6/index.html">spgrass6</a>,
-mantained by Roger Bivand
-<br><br>
-v.krige's <a href="http://grass.osgeo.org/wiki/V.krige_GSoC_2009">wiki page</a>
-
-<h2>REFERENCES</h2>
-
-Isaaks and Srivastava, 1989: "An Introduction to Applied Geostatistics" (ISBN 0-19-505013-4)
-
-<h2>AUTHOR</h2>
-
-Anne Ghisla, Google Summer of Code 2009
-
-<p>
-<i>Last changed: $Date$</i>
-
Copied: grass/trunk/scripts/v.krige/v.krige.html (from rev 39246, grass-addons/vector/v.krige/description.html)
===================================================================
--- grass/trunk/scripts/v.krige/v.krige.html (rev 0)
+++ grass/trunk/scripts/v.krige/v.krige.html 2009-12-18 15:04:47 UTC (rev 40045)
@@ -0,0 +1,178 @@
+<h2>DESCRIPTION</h2>
+
+<em>v.krige</em> allows to perform kriging operations in GRASS
+environment, using R software functions in background.
+
+<h2>NOTES</h2>
+
+<em>v.krige</em> is just a front-end to R. The options and parameters
+are the same offered by packages <i>automap</i> and <i>gstat</i>.
+
+<p>
+Kriging, like other interpolation methods, is fully dependent on input
+data features. Exploratory analysis of data is encouraged to find out
+outliers, trends, anisotropies, uneven distributions and consequently
+choose the kriging algorithm that will give the most acceptable
+result. Good knowledge of the dataset is more valuable than hundreds
+of parameters or powerful hardware. See Isaaks and Srivastava's book,
+exhaustive and clear even if a bit outdated.
+
+<h3>Dependencies</h3>
+
+<dl>
+<dt><b>R software >= 2.x</b></dt>
+<dd></dd>
+
+<dt><b>rpy2</b></dt>
+<dd>Python binding to R. Note! rpy is not supported.</dd>
+
+<dt><b>R packages automap and gstat. </b></dt>
+<dd>automap is optional (provides automatic variogram fit).</dd>
+</dl>
+
+<h4>Notes for Debian GNU/Linux</h4>
+
+Install the dependiencies. <b>Attention! python-rpy IS NOT
+SUITABLE.</b>:
+
+<div class="code"><pre>
+ aptitude install R python-rpy2
+<pre></div>
+
+To install R packages, use either R's function (as root):
+
+<div class="code"><pre>
+ install.packages("gstat", dep=T)
+ install.packages("spgrass6", dep=T)
+<pre></div>
+
+either the brand new Debian packages [5], add to repositories' list
+for 32bit or 64bit (pick up the suitable line):
+
+<div class="code"><pre>
+ deb <a href="http://debian.cran.r-project.org/cran2deb/debian-i386">http://debian.cran.r-project.org/cran2deb/debian-i386</a> testing/
+ deb <a href="http://debian.cran.r-project.org/cran2deb/debian-amd64">http://debian.cran.r-project.org/cran2deb/debian-amd64</a> testing/
+<pre></div>
+
+and get the packages via aptitude:
+
+<div class="code"><pre>
+ aptitude install r-cran-gstat r-cran-spgrass6
+<pre></div>
+
+<h4>Notes for Windows</h4>
+
+Compile GRASS following this
+<a href="http://trac.osgeo.org/grass/wiki/CompileOnWindows">guide</a>.
+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.
+
+<h3>Computation time issues</h3>
+
+Please note that kriging calculation is slown down both by high number
+of input data points and/or high region resolution, even if they both
+contribute to a better output.
+
+<h2>EXAMPLES</h2>
+
+Kriging example based on elevation map (Spearfish data set).
+
+<p>
+<b>Part 1: random sampling</b> of 2000 vector points from known
+elevation map. Each point will receive the elevation value from the
+elevation raster, as if it came from a point survey.
+
+<div class="code"><pre>
+ g.region rast=elevation.10m -p
+ v.random output=rand2k_elev n=2000
+ v.db.addtable map=rand2k_elev column="elevation double precision"
+ v.what.rast vect=rand2k_elev rast=elevation.10m column=elevation
+<pre></div>
+
+<b>Part 2: remove points lacking elevation attributes</b>. Points
+sampled at the border of the elevation map didn't receive any
+value. v.krige has no preferred action to cope with no data values, so
+the user must check for them and decide what to do (remove points,
+fill with the value of the nearest point, fill with the global/local
+mean...). In the following line of code, points with no data are
+removed from the map.
+
+<div class="code"><pre>
+ v.extract rand2k_elev output=rand2k_elev_filt where="elevation not NULL"
+<pre></div>
+
+Check the result of previous line ("number of NULL attributes" must be
+0):
+
+<div class="code"><pre>
+ v.univar rand2k_elev_filt type=point column=elevation
+<pre></div>
+
+<b>Part 3: reconstruct DEM through kriging</b>. Using automatic
+variogram fit is the simplest way to run v.krige from CLI (note:
+requires R's automap package). Output map name is optional, the
+modules creates it automatically appending "_kriging" the the input
+map name and also checks for overwrite. If output_var is specified,
+the variance map is also created. Automatic variogram fit is provided
+by R package automap, the variogram models tested by the fitting
+functions are: exponential, spherical, Gaussian, Matern, M.Stein's
+parametrisation. A wider range of models is available from gstat
+package and can be tested on the GUI via the variogram plotting. If
+model is specified in the CLI, also sill, nugget and range values are
+to be provided, otherwise an error is raised (see second example of
+v.krige command).
+
+<div class="code"><pre>
+ v.krige input=rand2k_elev_filt column=elevation output=rand2k_elev_kriging \
+ output_var=rand2k_elev_kriging_var
+ v.krige input=rand2k_elev_filt column=elevation output=rand2k_elev_kriging \
+ output_var=rand2k_elev_kriging_var model=Lin sill=2500 nugget=0 range=1000 \
+ --overwrite
+<pre></div>
+
+Or run wxGUI, to interactively fit the variogram and explore options:
+
+<div class="code"><pre>
+ v.krige
+</pre></div>
+
+<b>Calculate prediction error</b>:
+
+<div class="code"><pre>
+ r.mapcalc "rand2k_elev_kriging_pe = sqrt(rand2k_elev_kriging_var)"
+ r.univar elevation.10m
+ r.univar rand2k_elev_kriging
+ r.univar rand2k_elev_kriging_pe
+<pre></div>
+
+The results show high errors, as the kriging techniques (ordinary and
+block kriging) are unable to handle a dataset with a trend, like the
+one used in this example: elevation is higher in the southwest corner
+and lower on northeast corner. Universal kriging can give far better
+results in these cases as it can handle the trend. It is available in
+R package gstat and will be part of a future v.krige release.
+
+<h2>SEE ALSO</h2>
+
+R package <a href="http://cran.r-project.org/web/packages/gstat/index.html">gstat</a>,
+mantained by Edzer J. Pebesma and others
+<br>
+
+R
+package <a href="http://cran.r-project.org/web/packages/spgrass6/index.html">spgrass6</a>,
+mantained by Roger Bivand
+<br><br>
+
+v.krige's <a href="http://grass.osgeo.org/wiki/V.krige_GSoC_2009">wiki page</a>
+
+<h2>REFERENCES</h2>
+
+Isaaks and Srivastava, 1989: "An Introduction to Applied Geostatistics" (ISBN 0-19-505013-4)
+
+<h2>AUTHOR</h2>
+
+Anne Ghisla, Google Summer of Code 2009
+
+<p>
+<i>Last changed: $Date$</i>
Modified: grass/trunk/scripts/v.krige/v.krige.py
===================================================================
--- grass-addons/vector/v.krige/v.krige.py 2009-09-18 06:25:02 UTC (rev 39246)
+++ grass/trunk/scripts/v.krige/v.krige.py 2009-12-18 15:04:47 UTC (rev 40045)
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+
"""
MODULE: v.krige
@@ -19,7 +20,7 @@
#%module
#% description: Performs ordinary or block kriging.
-#% keywords: vector, kriging
+#% keywords: vector, interpolation, kriging
#%end
#%option
@@ -32,7 +33,8 @@
#%option
#% key: column
#% type: string
-#% description: Column with numerical value to be interpolated
+#% gisprompt: old,dbcolumn,dbcolumn
+#% description: Name of attribute column with numerical value to be interpolated
#% required : yes
#%end
#%option
@@ -122,7 +124,7 @@
### i18N
import gettext
-gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
+gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
### dependencies to be checked once, as they are quite time-consuming. cfr. grass.parser.
# GRASS binding
@@ -153,29 +155,29 @@
Checks for NULL values in the provided column and exits if they are present."""
#@NOTE: it alters original data. Is it correct? Shall I remove those columns
# if they were absent from original data?
- cols = grass.vector_columns(map=map, layer=1)
+ cols = grass.vector_columns(map = map, layer = 1)
if not cols.has_key('x') and not cols.has_key('y'):
- grass.run_command('v.db.addcol', map = map,
+ grass.run_command('v.db.addcolumn', map = map,
columns = 'x double precision, y double precision')
grass.run_command('v.to.db', map = map, option = 'coor', col = 'x,y')
- nulls = int(grass.parse_command('v.univar', map=map, column=column, type='point', \
- parse = (grass.parse_key_val, \
+ nulls = int(grass.parse_command('v.univar', map = map, column = column, type = 'point', \
+ parse = (grass.parse_key_val, \
{'sep':': '}))['number of NULL attributes'])
if nulls > 0:
grass.fatal(_("%d NULL value(s) in the selected column - unable to perform kriging.") % nulls)
- return robjects.r.readVECT6(map, type= 'point')
+ return robjects.r.readVECT6(map, type = 'point')
def CreateGrid(self, inputdata):
Grid = robjects.r.gmeta2grd()
# addition of coordinates columns into dataframe.
coordinatesDF = robjects.r['as.data.frame'](robjects.r.coordinates(Grid))
- data=robjects.r['data.frame'](x=coordinatesDF.r['s1'][0],
- y=coordinatesDF.r['s2'][0],
- k=robjects.r.rep(1, Region['cols']*Region['rows']))
+ data = robjects.r['data.frame'](x = coordinatesDF.r['s1'][0],
+ y = coordinatesDF.r['s2'][0],
+ k = robjects.r.rep(1, Region['cols']*Region['rows']))
GridPredicted = robjects.r.SpatialGridDataFrame(Grid,
data,
- proj4string= robjects.r.CRS(robjects.r.proj4string(inputdata)))
+ proj4string = robjects.r.CRS(robjects.r.proj4string(inputdata)))
return GridPredicted
def ComposeFormula(self, column, isblock, inputdata):
@@ -291,13 +293,13 @@
self.border = 4
# 1. Input data
- InputBoxSizer = wx.StaticBoxSizer(wx.StaticBox(self, id=wx.ID_ANY, label=_("Input Data")),
- orient=wx.HORIZONTAL)
+ InputBoxSizer = wx.StaticBoxSizer(wx.StaticBox(self, id = wx.ID_ANY, label = _("Input Data")),
+ orient = wx.HORIZONTAL)
- flexSizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5)
+ flexSizer = wx.FlexGridSizer(cols = 3, hgap = 5, vgap = 5)
flexSizer.AddGrowableCol(1)
- flexSizer.Add(item = wx.StaticText(self, id=wx.ID_ANY, label=_("Point dataset:")),
+ flexSizer.Add(item = wx.StaticText(self, id = wx.ID_ANY, label = _("Point dataset:")),
flag = wx.ALIGN_CENTER_VERTICAL)
self.InputDataMap = gselect.VectorSelect(parent = self,
ftype = 'points',
@@ -305,13 +307,13 @@
self.InputDataMap.SetFocus()
flexSizer.Add(item = self.InputDataMap, flag = wx.ALIGN_CENTER_VERTICAL)
- RefreshButton = wx.Button(self, id=wx.ID_REFRESH)
+ RefreshButton = wx.Button(self, id = wx.ID_REFRESH)
RefreshButton.Bind(wx.EVT_BUTTON, self.OnButtonRefresh)
flexSizer.Add(item = RefreshButton, flag = wx.ALIGN_CENTER_VERTICAL)
- flexSizer.Add(item = wx.StaticText(self, id=wx.ID_ANY, label=_("Numeric column:")),
- flag=wx.ALIGN_CENTER_VERTICAL)
- self.InputDataColumn = gselect.ColumnSelect(self, id=wx.ID_ANY)
+ flexSizer.Add(item = wx.StaticText(self, id = wx.ID_ANY, label = _("Numeric column:")),
+ flag = wx.ALIGN_CENTER_VERTICAL)
+ self.InputDataColumn = gselect.ColumnSelect(self, id = wx.ID_ANY)
self.InputDataColumn.SetSelection(0)
flexSizer.Add(item = self.InputDataColumn)
@@ -320,10 +322,10 @@
InputBoxSizer.Add(item = flexSizer)
# 2. Kriging. In book pages one for each R package. Includes variogram fit.
- KrigingSizer = wx.StaticBoxSizer(wx.StaticBox(self, id=wx.ID_ANY, label=_("Kriging")), wx.HORIZONTAL)
+ KrigingSizer = wx.StaticBoxSizer(wx.StaticBox(self, id = wx.ID_ANY, label = _("Kriging")), wx.HORIZONTAL)
- self.RPackagesBook = FN.FlatNotebook(parent=self, id=wx.ID_ANY,
- style=FN.FNB_BOTTOM |
+ self.RPackagesBook = FN.FlatNotebook(parent = self, id = wx.ID_ANY,
+ style = FN.FNB_BOTTOM |
FN.FNB_NO_NAV_BUTTONS |
FN.FNB_FANCY_TABS | FN.FNB_NO_X_BUTTON)
@@ -331,29 +333,29 @@
self.CreatePage(package = Rpackage)
## Command output. From menuform module, cmdPanel class
- self.goutput = goutput.GMConsole(parent=self, margin=False,
- pageid=self.RPackagesBook.GetPageCount(),
+ self.goutput = goutput.GMConsole(parent = self, margin = False,
+ pageid = self.RPackagesBook.GetPageCount(),
notebook = self.RPackagesBook)
self.goutputId = self.RPackagesBook.GetPageCount()
- self.outpage = self.RPackagesBook.AddPage(self.goutput, text=_("Command output"))
+ self.outpage = self.RPackagesBook.AddPage(self.goutput, text = _("Command output"))
self.RPackagesBook.SetSelection(0)
- KrigingSizer.Add(self.RPackagesBook, proportion=1, flag=wx.EXPAND)
+ KrigingSizer.Add(self.RPackagesBook, proportion = 1, flag = wx.EXPAND)
# 3. Output Parameters.
- OutputSizer = wx.StaticBoxSizer(wx.StaticBox(self, id=wx.ID_ANY, label=_("Output")), wx.HORIZONTAL)
+ OutputSizer = wx.StaticBoxSizer(wx.StaticBox(self, id = wx.ID_ANY, label = _("Output")), wx.HORIZONTAL)
- OutputParameters = wx.GridBagSizer(hgap=5, vgap=5)
+ OutputParameters = wx.GridBagSizer(hgap = 5, vgap = 5)
OutputParameters.AddGrowableCol(1)
- OutputParameters.Add(item = wx.StaticText(self, id=wx.ID_ANY, label=_("Name for the output raster map:")),
+ OutputParameters.Add(item = wx.StaticText(self, id = wx.ID_ANY, label = _("Name for the output raster map:")),
flag = wx.ALIGN_CENTER_VERTICAL,
pos = (0, 0))
self.OutputMapName = gselect.Select(parent = self, id = wx.ID_ANY,
type = 'raster',
mapsets = [grass.gisenv()['MAPSET']])
- OutputParameters.Add(item=self.OutputMapName, flag=wx.EXPAND | wx.ALL,
+ OutputParameters.Add(item = self.OutputMapName, flag = wx.EXPAND | wx.ALL,
pos = (0, 1))
- self.VarianceRasterCheckbox = wx.CheckBox(self, id=wx.ID_ANY, label=_("Export variance map as well: "))
+ self.VarianceRasterCheckbox = wx.CheckBox(self, id = wx.ID_ANY, label = _("Export variance map as well: "))
self.VarianceRasterCheckbox.SetValue(state = True)
OutputParameters.Add(item = self.VarianceRasterCheckbox,
flag = wx.ALIGN_CENTER_VERTICAL,
@@ -362,36 +364,36 @@
type = 'raster',
mapsets = [grass.gisenv()['MAPSET']])
self.VarianceRasterCheckbox.Bind(wx.EVT_CHECKBOX, self.OnVarianceCBChecked)
- OutputParameters.Add(item=self.OutputVarianceMapName, flag=wx.EXPAND | wx.ALL,
+ OutputParameters.Add(item = self.OutputVarianceMapName, flag = wx.EXPAND | wx.ALL,
pos = (1, 1))
- self.OverwriteCheckBox = wx.CheckBox(self, id=wx.ID_ANY,
- label=_("Allow output files to overwrite existing files"))
+ self.OverwriteCheckBox = wx.CheckBox(self, id = wx.ID_ANY,
+ label = _("Allow output files to overwrite existing files"))
self.OverwriteCheckBox.SetValue(state = False)
OutputParameters.Add(item = self.OverwriteCheckBox,
pos = (2, 0), span = (1, 2))
- OutputSizer.Add(OutputParameters, proportion=0, flag=wx.EXPAND | wx.ALL, border=self.border)
+ OutputSizer.Add(OutputParameters, proportion = 0, flag = wx.EXPAND | wx.ALL, border = self.border)
# 4. Run Button and Quit Button
ButtonSizer = wx.BoxSizer(wx.HORIZONTAL)
- HelpButton = wx.Button(self, id=wx.ID_HELP)
+ HelpButton = wx.Button(self, id = wx.ID_HELP)
HelpButton.Bind(wx.EVT_BUTTON, self.OnHelpButton)
- QuitButton = wx.Button(self, id=wx.ID_EXIT)
+ QuitButton = wx.Button(self, id = wx.ID_EXIT)
QuitButton.Bind(wx.EVT_BUTTON, self.OnCloseWindow)
- self.RunButton = wx.Button(self, id=wx.ID_ANY, label=_("Run")) # no stock ID for Run button..
+ self.RunButton = wx.Button(self, id = wx.ID_ANY, label = _("&Run")) # no stock ID for Run button..
self.RunButton.Bind(wx.EVT_BUTTON, self.OnRunButton)
self.RunButton.Enable(False) # disable it on loading the interface, as input map is not set
- ButtonSizer.Add(HelpButton, proportion=0, flag=wx.ALIGN_LEFT | wx.ALL, border=self.border)
- ButtonSizer.Add(QuitButton, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALL, border=self.border)
- ButtonSizer.Add(self.RunButton, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALL, border=self.border)
+ ButtonSizer.Add(HelpButton, proportion = 0, flag = wx.ALIGN_LEFT | wx.ALL, border = self.border)
+ ButtonSizer.Add(QuitButton, proportion = 0, flag = wx.ALIGN_RIGHT | wx.ALL, border = self.border)
+ ButtonSizer.Add(self.RunButton, proportion = 0, flag = wx.ALIGN_RIGHT | wx.ALL, border = self.border)
# Main Sizer. Add each child sizer as soon as it is ready.
Sizer = wx.BoxSizer(wx.VERTICAL)
- Sizer.Add(InputBoxSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=self.border)
- Sizer.Add(KrigingSizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=self.border)
- Sizer.Add(OutputSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=self.border)
- Sizer.Add(ButtonSizer, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALL, border=self.border)
+ Sizer.Add(InputBoxSizer, proportion = 0, flag = wx.EXPAND | wx.ALL, border = self.border)
+ Sizer.Add(KrigingSizer, proportion = 1, flag = wx.EXPAND | wx.ALL, border = self.border)
+ Sizer.Add(OutputSizer, proportion = 0, flag = wx.EXPAND | wx.ALL, border = self.border)
+ Sizer.Add(ButtonSizer, proportion = 0, flag = wx.ALIGN_RIGHT | wx.ALL, border = self.border)
self.SetSizerAndFit(Sizer)
# last action of __init__: update imput data list.
@@ -403,8 +405,8 @@
""" Creates the three notebook pages, one for each R package """
for package in ["gstat"]:
classobj = eval("RBook"+package+"Panel")
- setattr(self, "RBook"+package+"Panel", (classobj(self, id=wx.ID_ANY)))
- self.RPackagesBook.AddPage(page=getattr(self, "RBook"+package+"Panel"), text=package)
+ setattr(self, "RBook"+package+"Panel", (classobj(self, id = wx.ID_ANY)))
+ self.RPackagesBook.AddPage(page = getattr(self, "RBook"+package+"Panel"), text = package)
def OnButtonRefresh(self, event):
""" Forces refresh of list of available layers. """
@@ -416,16 +418,16 @@
event.Skip()
def OnHelpButton(self, event):
- # file = os.path.join(os.getenv("GISBASE"), "docs", "html", "v.krige.py.html")
+ # file = os.path.join(os.getenv("GISBASE"), "docs", "html", "v.krige.html")
# file = os.path.join(os.path.curdir, "description.html")
# @TODO fix HelpWindow
# helpFrame = help.HelpWindow(parent=self, id=wx.ID_ANY,
- # title=_("GRASS - Help page for v.krige.py"),
+ # title=_("GRASS - Help page for v.krige"),
# size=(640, 480),
# file=file)
# helpFrame.Show(True)
- grass.run_command('g.manual', entry = 'v.krige.py')
+ grass.run_command('g.manual', entry = 'v.krige')
event.Skip()
@@ -459,10 +461,10 @@
return False # no break invoked by above function
# mount command string as it would have been written on CLI
- command = ["v.krige.py", "input=" + self.InputDataMap.GetValue(),
- "column=" + self.InputDataColumn.GetValue(),
- "output=" + self.OutputMapName.GetValue(),
- "package=" + '%s' % self.RPackagesBook.GetPageText(self.RPackagesBook.GetSelection())]
+ command = ["v.krige", "input=" + self.InputDataMap.GetValue(),
+ "column=" + self.InputDataColumn.GetValue(),
+ "output=" + self.OutputMapName.GetValue(),
+ "package=" + '%s' % self.RPackagesBook.GetPageText(self.RPackagesBook.GetSelection())]
if not hasattr(SelectedPanel, 'VariogramCheckBox') or not SelectedPanel.VariogramCheckBox.IsChecked():
command.append("model=" + '%s' % SelectedPanel.ModelChoicebox.GetStringSelection().split(" ")[0])
@@ -518,36 +520,36 @@
self.parent = parent
self.VariogramSizer = wx.StaticBoxSizer(wx.StaticBox(self,
- id=wx.ID_ANY,
- label=_("Variogram fitting")),
+ id = wx.ID_ANY,
+ label = _("Variogram fitting")),
wx.HORIZONTAL)
self.LeftSizer = wx.BoxSizer(wx.VERTICAL)
self.RightSizer = wx.BoxSizer(wx.VERTICAL)
- self.ParametersSizer = wx.GridBagSizer(vgap=5, hgap=5)
+ self.ParametersSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
- self.VariogramSizer.Add(self.LeftSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=parent.border)
- self.VariogramSizer.Add(self.RightSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=parent.border)
+ self.VariogramSizer.Add(self.LeftSizer, proportion = 0, flag = wx.EXPAND | wx.ALL, border = parent.border)
+ self.VariogramSizer.Add(self.RightSizer, proportion = 0, flag = wx.EXPAND | wx.ALL, border = parent.border)
# left side of Variogram fitting. The checkboxes and spinctrls.
- self.PlotButton = wx.Button(self, id=wx.ID_ANY, label=_("Plot/refresh variogram")) # no stock ID for Run button..
+ self.PlotButton = wx.Button(self, id = wx.ID_ANY, label = _("Plot/refresh variogram")) # no stock ID for Run button..
self.PlotButton.Bind(wx.EVT_BUTTON, self.OnPlotButton)
self.PlotButton.Enable(False) # grey it out until a suitable layer is available
- self.LeftSizer.Add(self.PlotButton, proportion=0, flag= wx.ALL, border=parent.border)
- self.LeftSizer.Add(self.ParametersSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=parent.border)
+ self.LeftSizer.Add(self.PlotButton, proportion = 0, flag = wx.ALL, border = parent.border)
+ self.LeftSizer.Add(self.ParametersSizer, proportion = 0, flag = wx.EXPAND | wx.ALL, border = parent.border)
self.ParametersList = ["Sill", "Nugget", "Range"]
MinValues = [0,0,1]
for n in self.ParametersList:
setattr(self, n+"ChextBox", wx.CheckBox(self,
- id=self.ParametersList.index(n),
- label=_(n + ":")))
+ id = self.ParametersList.index(n),
+ label = _(n + ":")))
setattr(self, n+"Ctrl", (wx.SpinCtrl(self,
id = wx.ID_ANY,
min = MinValues[self.ParametersList.index(n)],
- max=maxint)))
+ max = maxint)))
getattr(self, n+"ChextBox").Bind(wx.EVT_CHECKBOX,
self.UseValue,
- id=self.ParametersList.index(n))
+ id = self.ParametersList.index(n))
setattr(self, n+"Sizer", (wx.BoxSizer(wx.HORIZONTAL)))
self.ParametersSizer.Add(getattr(self, n+"ChextBox"),
flag = wx.ALIGN_CENTER_VERTICAL,
@@ -564,31 +566,31 @@
#self.RightSizer.Add(PlotPanel, proportion=0, flag= wx.EXPAND|wx.ALL, border=parent.border)
self.KrigingSizer = wx.StaticBoxSizer(wx.StaticBox(self,
- id=wx.ID_ANY,
- label=_("Kriging techniques")),
+ id = wx.ID_ANY,
+ label = _("Kriging techniques")),
wx.VERTICAL)
KrigingList = ["Ordinary kriging", "Block kriging"]#, "Universal kriging"] #@FIXME: i18n on the list?
self.KrigingRadioBox = wx.RadioBox(self,
- id=wx.ID_ANY,
- choices=KrigingList,
- majorDimension=1,
- style=wx.RA_SPECIFY_COLS)
+ id = wx.ID_ANY,
+ choices = KrigingList,
+ majorDimension = 1,
+ style = wx.RA_SPECIFY_COLS)
self.KrigingRadioBox.Bind(wx.EVT_RADIOBOX, self.HideBlockOptions)
- self.KrigingSizer.Add(self.KrigingRadioBox, proportion=0, flag=wx.EXPAND | wx.ALL, border=parent.border)
+ self.KrigingSizer.Add(self.KrigingRadioBox, proportion = 0, flag = wx.EXPAND | wx.ALL, border = parent.border)
# block kriging parameters. Size.
BlockSizer = wx.BoxSizer(wx.HORIZONTAL)
- BlockLabel = wx.StaticText(self, id= wx.ID_ANY, label = _("Block size:"))
- self.BlockSpinBox = wx.SpinCtrl(self, id = wx.ID_ANY, min=1, max=maxint)
+ BlockLabel = wx.StaticText(self, id = wx.ID_ANY, label = _("Block size:"))
+ self.BlockSpinBox = wx.SpinCtrl(self, id = wx.ID_ANY, min = 1, max = maxint)
self.BlockSpinBox.Enable(False) # default choice is Ordinary kriging so block param is disabled
- BlockSizer.Add(BlockLabel, flag= wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=parent.border)
- BlockSizer.Add(self.BlockSpinBox, flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=parent.border)
- self.KrigingSizer.Add(BlockSizer, flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=parent.border)
+ BlockSizer.Add(BlockLabel, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALL, border = parent.border)
+ BlockSizer.Add(self.BlockSpinBox, flag = wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, border = parent.border)
+ self.KrigingSizer.Add(BlockSizer, flag = wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, border = parent.border)
self.Sizer = wx.BoxSizer(wx.VERTICAL)
- self.Sizer.Add(self.VariogramSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=parent.border)
- self.Sizer.Add(self.KrigingSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=parent.border)
+ self.Sizer.Add(self.VariogramSizer, proportion = 0, flag = wx.EXPAND | wx.ALL, border = parent.border)
+ self.Sizer.Add(self.KrigingSizer, proportion = 0, flag = wx.EXPAND | wx.ALL, border = parent.border)
def HideBlockOptions(self, event):
self.BlockSpinBox.Enable(event.GetInt() == 1)
@@ -608,12 +610,12 @@
RBookPanel.__init__(self, parent, *args, **kwargs)
if robjects.r.require('automap')[0]:
- self.VariogramCheckBox = wx.CheckBox(self, id=wx.ID_ANY, label=_("Auto-fit variogram"))
+ self.VariogramCheckBox = wx.CheckBox(self, id = wx.ID_ANY, label = _("Auto-fit variogram"))
self.LeftSizer.Insert(0,
self.VariogramCheckBox,
- proportion=0,
- flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
- border=4)
+ proportion = 0,
+ flag = wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
+ border = 4)
self.SetSizerAndFit(self.Sizer)
self.VariogramCheckBox.Bind(wx.EVT_CHECKBOX, self.HideOptions)
self.VariogramCheckBox.SetValue(state = True) # check it by default
@@ -622,7 +624,7 @@
ModelList = robjects.r.levels(ModelFactor[0])
#@FIXME: no other way to let the Python pick it up..
# and this is te wrong place where to load this list. should be at the very beginning.
- self.ModelChoicebox = wx.Choice(self, id=wx.ID_ANY, choices=ModelList)
+ self.ModelChoicebox = wx.Choice(self, id = wx.ID_ANY, choices = ModelList)
# disable model parameters' widgets by default
for n in ["Sill", "Nugget", "Range"]:
@@ -630,16 +632,16 @@
self.ModelChoicebox.Enable(False)
VariogramSubSizer = wx.BoxSizer(wx.HORIZONTAL)
- VariogramSubSizer.Add(item=wx.StaticText(self,
- id= wx.ID_ANY,
+ VariogramSubSizer.Add(item = wx.StaticText(self,
+ id = wx.ID_ANY,
label = _("Model: ")),
- flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL,
- border=4)
- VariogramSubSizer.Add(item=self.ModelChoicebox,
- flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL,
- border=4)
+ flag = wx.ALIGN_CENTER_VERTICAL | wx.ALL,
+ border = 4)
+ VariogramSubSizer.Add(item = self.ModelChoicebox,
+ flag = wx.ALIGN_CENTER_VERTICAL | wx.ALL,
+ border = 4)
- self.LeftSizer.Insert(2, item= VariogramSubSizer)
+ self.LeftSizer.Insert(2, item = VariogramSubSizer)
self.SetSizerAndFit(self.Sizer)
@@ -744,10 +746,10 @@
#@TODO: change these two lines as soon as geoR f(x)s are integrated.
for n in self.GetChildren():
n.Hide()
- self.Sizer.Add(wx.StaticText(self, id= wx.ID_ANY, label = _("Work in progress! No functionality provided.")))
+ self.Sizer.Add(wx.StaticText(self, id = wx.ID_ANY, label = _("Work in progress! No functionality provided.")))
self.SetSizerAndFit(self.Sizer)
-def main(argv=None):
+def main(argv = None):
#@FIXME: solve this double ifelse. the control should not be done twice.
if argv is None:
@@ -755,7 +757,7 @@
argv = sys.argv[1:] #stripping first item, the full name of this script
# wxGUI call.
app = wx.App()
- KrigingFrame = KrigingModule(parent=None)
+ KrigingFrame = KrigingModule(parent = None)
KrigingFrame.Centre()
KrigingFrame.Show()
app.MainLoop()
@@ -775,7 +777,7 @@
options['input'] = options['input'].split("@")[0]
except:
pass
- options['output'] = options['input'] + '_kriging'
+ options['output'] = options['input'] + '_kriging'
# check for output map with same name. g.parser can't handle this, afaik.
if grass.find_file(options['output'], element = 'cell')['fullname'] and os.getenv("GRASS_OVERWRITE") == None:
@@ -850,11 +852,11 @@
# R packages check.
# @FIXME: it leaves a Rtmpxxxx folder into the make tempfolder and causes make complain. [markus]
for each in ["gstat", "spgrass6"]:
- if not robjects.r.require(each, quietly=True)[0]:
+ if not robjects.r.require(each, quietly = True)[0]:
sys.exit(_("R package " + each + " is missing. Install it and re-run v.krige."))
if __name__ == '__main__':
if len(sys.argv) > 1:
- sys.exit(main(argv=grass.parser()))
+ sys.exit(main(argv = grass.parser()))
else:
main()
More information about the grass-commit
mailing list