[GRASS-SVN] r50114 -
grass/branches/develbranch_6/scripts/r.fillnulls
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jan 9 16:57:41 EST 2012
Author: neteler
Date: 2012-01-09 13:57:41 -0800 (Mon, 09 Jan 2012)
New Revision: 50114
Modified:
grass/branches/develbranch_6/scripts/r.fillnulls/description.html
grass/branches/develbranch_6/scripts/r.fillnulls/r.fillnulls
Log:
added v.surf.bsplines support
Modified: grass/branches/develbranch_6/scripts/r.fillnulls/description.html
===================================================================
--- grass/branches/develbranch_6/scripts/r.fillnulls/description.html 2012-01-09 21:21:25 UTC (rev 50113)
+++ grass/branches/develbranch_6/scripts/r.fillnulls/description.html 2012-01-09 21:57:41 UTC (rev 50114)
@@ -2,8 +2,8 @@
<em>r.fillnulls</em> fills NULL pixels (no data areas) in input map and
stores filled map to a new output map. The fill data are interpolated
-from the no data area boundaries buffer using <em>v.surf.rst</em>
-spline interpolation.
+from the no data area boundaries buffer using <em>v.surf.rst</em> or
+<em>v.surf.bspline</em> interpolation.
<h2>NOTES</h2>
@@ -12,7 +12,7 @@
a trained slope and curvature at the edges, in order to avoid that such a flat plane
is generated in a hole.
<p>
-During the interpolation following warning may occur:<p>
+During the interpolation following warning may occur when using the RST method:<p>
<tt>
Warning: strip exists with insufficient data<br>
@@ -27,13 +27,16 @@
<h2>NOTES</h2>
-The algorithm is based on <em>v.surf.rst</em>
+When using the default RST method, the algorithm is based on <em>v.surf.rst</em>
regularized splines with tension interpolation module which interpolates the
raster cell values for NULL data areas from the boundary values of the NULL
data area. An eventual raster MASK is respected during the NULL data area(s)
filling. The interpolated values are patched into the NULL data area(s) of
the input map and saved into a new raster map.
+Otherwise, ither the bilinear or bicubic method can be selected (based on
+<em>v.surf.bspline</em>.
+
<h2>WARNING</h2>
Depending on the shape of the NULL data area(s) problems may occur due to an
@@ -41,7 +44,8 @@
problems will occur if a NULL data area reaches a large amount of the map
boundary. The user will have to carefully check the result using
<em>r.mapcalc</em> (generating a difference map to the
-input map) and/or <em>d.what.rast</em> to query individual cell values.
+input map and applying the "differences" color table with <em>r.colors</em>)
+and/or <em>d.what.rast</em> to query individual cell values.
<h2>EXAMPLE</h2>
@@ -69,6 +73,7 @@
<em>
<a href="r.fill.dir.html">r.fill.dir</a>,
<a href="r.mapcalc.html">r.mapcalc</a>,
+<a href="v.surf.bspline.html">v.surf.bspline</a>
<a href="v.surf.rst.html">v.surf.rst</a>
</em>
@@ -94,7 +99,7 @@
<i>Mathematical Geology</i> 25, 657-667.
<h2>AUTHORS</h2>
-r.fillnulls: Markus Neteler, University of Hannover<p>
+r.fillnulls: Markus Neteler, University of Hannover and Fondazione Edmund Mach<p>
and authors of v.surf.rst<br>
Improvement by Hamish Bowman, NZ
Modified: grass/branches/develbranch_6/scripts/r.fillnulls/r.fillnulls
===================================================================
--- grass/branches/develbranch_6/scripts/r.fillnulls/r.fillnulls 2012-01-09 21:21:25 UTC (rev 50113)
+++ grass/branches/develbranch_6/scripts/r.fillnulls/r.fillnulls 2012-01-09 21:57:41 UTC (rev 50114)
@@ -3,14 +3,15 @@
############################################################################
#
# MODULE: r.fillnulls
-# AUTHOR(S): Markus Neteler <neteler itc it>
+# AUTHOR(S): Markus Neteler
# Updated to GRASS 5.7 by Michael Barton
# Updated to GRASS 6.0 by Markus Neteler
# Ring improvements by Hamish Bowman
+# v.surf.bspline support by Markus Neteler
# PURPOSE: fills NULL (no data areas) in raster maps
# The script respects a user mask (MASK) if present.
#
-# COPYRIGHT: (C) 2001,2004-2005 by the GRASS Development Team
+# COPYRIGHT: (C) 2001-2012 by the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
@@ -20,7 +21,7 @@
#%Module
-#% description: Fills no-data areas in raster maps using v.surf.rst splines interpolation.
+#% description: Fills no-data areas in raster maps using v.surf.rst splines or v.surf.bspline interpolation.
#% keywords: raster, elevation, interpolation
#%End
#%option
@@ -51,6 +52,14 @@
#% required : no
#% answer : 0.1
#%end
+#%option
+#% key: method
+#% type: string
+#% description: Interpolation method
+#% options:bilinear,bicubic,rst
+#% answer:rst
+#% required:yes
+#%end
if test "$GISBASE" = ""; then
echo "You must be in GRASS GIS to run this program." >&2
@@ -115,6 +124,10 @@
g.message -e "<$GIS_OPT_INPUT> does not exist! Aborting."
exit 1
fi
+case "$GIS_OPT_METHOD" in
+ rst | bilinear | bicubic) ;;
+ *) GIS_OPT_METHOD=rst ;;
+esac
#check if a MASK is already present:
MASKTMP=mask.$$
@@ -170,6 +183,8 @@
g.rename "$USERMASK",MASK --quiet > /dev/null
exit 1
fi
+# this mask not needed any more
+g.remove rast=MASK --quiet
#count number of points to control segmax parameter for interpolation:
# check-me: quoting?
@@ -197,9 +212,11 @@
g.message "Note: The following warnings may be ignored."
-#remove internal MASK first -- WHY???? MN 10/2005
-g.remove MASK > /dev/null
+# rst
+if [ "$GIS_OPT_METHOD" = "rst" ] ; then
+g.message "Using RST interpolation"
+
eval `g.findfile element=cell file=$USERMASK`
if [ "$file" ] ; then
g.message "Using user mask while interpolating"
@@ -218,8 +235,6 @@
$RST_CMD input="$VECTTMP" elev="${TMP1}_filled" segmax="$SEGMAX" #2> /dev/null
fi
-g.message "Note: Above warnings may be ignored."
-
#restoring user's mask, if present:
eval `g.findfile element=cell file=$USERMASK`
if [ "$file" ] ; then
@@ -227,6 +242,30 @@
g.rename "$USERMASK",MASK --quiet > /dev/null
fi
+# bspline
+else
+
+g.message "Using $GIS_OPT_METHOD (v.surf.bspline) interpolation"
+
+#restoring user's mask, if present
+# pointless for now, since v.surf.bspline ignores MASK, but someday...
+if test -f $LOCATION/cell/$USERMASK
+then
+ g.message "Restoring user mask (MASK)..."
+ g.rename --q $USERMASK,MASK
+fi
+
+eval `g.region -g`
+SIE="`echo $ewres | cut -d'=' -f2 | awk '{printf "%f", $1 * 3.}'`"
+SIN="`echo $nsres | cut -d'=' -f2 | awk '{printf "%f", $1 * 3.}'`"
+
+v.surf.bspline input=${VECTTMP} raster=${TMP1}_filled method=$GIS_OPT_METHOD layer=1 column=value sie=${SIE} sin=${SIN}
+
+# rst or bspline
+fi
+
+g.message "Note: Above warnings may be ignored."
+
#patch orig and fill map
g.message "Patching fill data into NULL areas..."
# we can use --o here as g.parser already checks on startup
More information about the grass-commit
mailing list