[GRASS-SVN] r50117 -
grass/branches/develbranch_6/scripts/r.fillnulls
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jan 9 22:42:53 EST 2012
Author: hamish
Date: 2012-01-09 19:42:52 -0800 (Mon, 09 Jan 2012)
New Revision: 50117
Modified:
grass/branches/develbranch_6/scripts/r.fillnulls/r.fillnulls
Log:
simplify description;
note that the no-topology flag may be helpful;
minor indent;
*always* quote filenames and paths;
curly brackets do not act to quote variables. use double-quotes instead;
"taking too long" warnings only come from v.surf.rst AFAIK;
use g.findfile to test if a map exists;
remove superfluous `cut` from spline step calc (n.b. I'm not sure that the
wording is very clear in my earlier code comment, but the res*3 thing is
meant to be the conceptual equivalent of 'r.grow radius=3'. I assume that
setting the spline step to match this distance is what is intended).
Modified: grass/branches/develbranch_6/scripts/r.fillnulls/r.fillnulls
===================================================================
--- grass/branches/develbranch_6/scripts/r.fillnulls/r.fillnulls 2012-01-10 02:41:15 UTC (rev 50116)
+++ grass/branches/develbranch_6/scripts/r.fillnulls/r.fillnulls 2012-01-10 03:42:52 UTC (rev 50117)
@@ -21,7 +21,7 @@
#%Module
-#% description: Fills no-data areas in raster maps using v.surf.rst splines or v.surf.bspline interpolation.
+#% description: Fills no-data areas in raster maps using spline interpolation.
#% keywords: raster, elevation, interpolation
#%End
#%option
@@ -175,7 +175,10 @@
# Use this outline (raster border) for interpolating the fill data:
VECTTMP=vecttmp_fillnulls_$$
g.message "Creating interpolation points..."
+
+## use the -b flag to avoid topology building on big jobs?
r.to.vect input="$GIS_OPT_INPUT" output="$VECTTMP" feature=point
+
if [ $? -ne 0 ] ; then
g.message -e "$0 abandoned. Removing temporary maps, restoring user mask if needed:"
g.remove rast=MASK,"$TMP1","$TMP1.buf","${TMP1}_filled" --quiet > /dev/null
@@ -200,8 +203,8 @@
#restoring user's mask, if present:
eval `g.findfile element=cell file=$USERMASK`
if [ "$file" ] ; then
- g.message "Restoring user mask (MASK)..."
- g.rename "$USERMASK",MASK --quiet > /dev/null
+ g.message "Restoring user mask (MASK)..."
+ g.rename "$USERMASK",MASK --quiet > /dev/null
fi
#cleanup
@@ -210,61 +213,60 @@
exit 1
fi
-g.message "Note: The following warnings may be ignored."
-# rst
if [ "$GIS_OPT_METHOD" = "rst" ] ; then
-g.message "Using RST interpolation"
+ g.message "Using RST interpolation"
-eval `g.findfile element=cell file=$USERMASK`
-if [ "$file" ] ; then
- g.message "Using user mask while interpolating"
- RST_CMD="v.surf.rst zcol=value tension=$GIS_OPT_TENSION smooth=$GIS_OPT_SMOOTH maskmap=$USERMASK"
-else
- RST_CMD="v.surf.rst zcol=value tension=$GIS_OPT_TENSION smooth=$GIS_OPT_SMOOTH"
-fi
+ eval `g.findfile element=cell file=$USERMASK`
+ if [ "$file" ] ; then
+ g.message "Using user mask while interpolating"
+ RST_CMD="v.surf.rst zcol=value tension=$GIS_OPT_TENSION smooth=$GIS_OPT_SMOOTH maskmap=$USERMASK"
+ else
+ RST_CMD="v.surf.rst zcol=value tension=$GIS_OPT_TENSION smooth=$GIS_OPT_SMOOTH"
+ fi
-SEGMAX=600
-if [ "$POINTSNUMBER" -ge "$SEGMAX" ] ; then
- g.message "Using segmentation for interpolation..."
- $RST_CMD input="$VECTTMP" elev="${TMP1}_filled" #2> /dev/null
-else
- #if less than $SEGMAX points, use no segmentation for speedup:
- g.message "Using no segmentation for interpolation as not needed..."
- $RST_CMD input="$VECTTMP" elev="${TMP1}_filled" segmax="$SEGMAX" #2> /dev/null
-fi
+ g.message "Note: The following warnings may be ignored."
-#restoring user's mask, if present:
-eval `g.findfile element=cell file=$USERMASK`
-if [ "$file" ] ; then
- g.message "Restoring user mask (MASK)..."
- g.rename "$USERMASK",MASK --quiet > /dev/null
-fi
+ SEGMAX=600
+ if [ "$POINTSNUMBER" -ge "$SEGMAX" ] ; then
+ g.message "Using segmentation for interpolation..."
+ $RST_CMD input="$VECTTMP" elev="${TMP1}_filled" #2> /dev/null
+ else
+ #if less than $SEGMAX points, use no segmentation for speedup:
+ g.message "Not using segmentation for interpolation as it's not needed..."
+ $RST_CMD input="$VECTTMP" elev="${TMP1}_filled" segmax="$SEGMAX" #2> /dev/null
+ fi
+ g.message "Note: Above warnings may be ignored."
-# bspline
+ #restoring user's mask, if present:
+ eval `g.findfile element=cell file=$USERMASK`
+ if [ "$file" ] ; then
+ g.message "Restoring user mask (MASK)..."
+ g.rename "$USERMASK",MASK --quiet > /dev/null
+ fi
+
+
else
+ g.message "Using $GIS_OPT_METHOD (v.surf.bspline) interpolation"
-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...
+ eval `g.findfile element=cell file=$USERMASK`
+ if [ "$file" ] ; then
+ g.message "Restoring user mask (MASK)..."
+ g.rename "$USERMASK",MASK --quiet
+ fi
-#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" | awk '{printf "%f", $1 * 3.}'`
+ SIN=`echo "$nsres" | awk '{printf "%f", $1 * 3.}'`
-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" layer=1 \
+ method="$GIS_OPT_METHOD" column=value sie="$SIE" sin="$SIN"
-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..."
More information about the grass-commit
mailing list