[GRASS-dev] patch for v.rast.stats to use multiple percentiles

A little patch to permit the use of multiple percentiles inside v.rast.stats
http://www.geospatial.it/allegri/v.rast.stats.diff

Giovanni

Index: v.rast.stats

--- v.rast.stats (revisione 33591)
+++ v.rast.stats (copia locale)
@@ -63,6 +63,7 @@
#% options: 0-100
#% answer: 90
#% required : no
+#% multiple : yes
#%end

if [ -z "$GISBASE" ] ; then
@@ -221,12 +222,20 @@
# do extended stats?
if [ $GIS_FLAG_E -eq 1 ] ; then
    # namespace is limited in DBF but the % value is important
- if [ $DBFDRIVER -eq 1 ] ; then
- PERCCOL="per$GIS_OPT_PERCENTILE"
- else
- PERCCOL="percentile_$GIS_OPT_PERCENTILE"
- fi
- EXTRACOLS="first_quartile median third_quartile $PERCCOL"
+ PERCOL=""
+ percs=`echo $GIS_OPT_PERCENTILE | sed 's+,+ +g'`
+ if [ $DBFDRIVER -eq 1 ] ; then
+ PERCCOLPREF="per"
+ for p in $percs; do
+ PERCCOL="$PERCCOL $PERCCOLPREF$p"
+ done
+ else
+ PERCCOLPREF="percentile_"
+ for p in $percs; do
+ PERCCOL="$PERCCOL $PERCCOLPREF$p"
+ done
+ fi
+ EXTRACOLS="first_quartile median third_quartile$PERCCOL"
else
    EXTRACOLS=""
fi
@@ -298,7 +307,9 @@

    cf_var="$coeff_var"
    if [ $GIS_FLAG_E -eq 1 ] && [ $DBFDRIVER -eq 1 ] ; then
- eval "$PERCCOL=\$percentile_$GIS_OPT_PERCENTILE"
+ for p in $percs; do
+ eval "$PERCCOLPREF$p=\$percentile_$p"
+ done
    fi

    for var in $BASECOLS $EXTRACOLS ; do

On 29/09/08 15:13, G. Allegri wrote:

A little patch to permit the use of multiple percentiles inside v.rast.stats

nice, very useful.

+ EXTRACOLS="first_quartile median third_quartile$PERCCOL"

This should be

EXTRACOLS="first_quartile median third_quartile $PERCCOL"

Moritz

+ EXTRACOLS="first_quartile median third_quartile$PERCCOL"

This should be

EXTRACOLS="first_quartile median third_quartile $PERCCOL"

No, because $PERCCOL is built from iteration, so it contains an extra
space from the first loop.
Eventually it could be:
EXTRACOLS="first_quartile median third_quartile ${PERCCOL:1}"

G. Allegri wrote:

A little patch to permit the use of multiple percentiles inside v.rast.stats
http://www.geospatial.it/allegri/v.rast.stats.diff

Giovanni

Index: v.rast.stats

--- v.rast.stats (revisione 33591)
+++ v.rast.stats (copia locale)

v.rast.stats has been converted to Python:

http://trac.osgeo.org/grass/browser/grass/trunk/scripts/v.rast.stats/v.rast.stats.py

The shell version remains for reference, but will eventually be
removed.

Most of the other scripts will similarly be converted over the coming
days.

Please don't commit updates to shell versions of scripts which have
already been converted; update the Python version instead.

--
Glynn Clements <glynn@gclements.plus.com>

I didn't see the new versions of script. Wow, I've seen grass.py lib, very good!
Will all the scripts be converted?

2008/9/29 Glynn Clements <glynn@gclements.plus.com>:

G. Allegri wrote:

A little patch to permit the use of multiple percentiles inside v.rast.stats
http://www.geospatial.it/allegri/v.rast.stats.diff

Giovanni

Index: v.rast.stats

--- v.rast.stats (revisione 33591)
+++ v.rast.stats (copia locale)

v.rast.stats has been converted to Python:

http://trac.osgeo.org/grass/browser/grass/trunk/scripts/v.rast.stats/v.rast.stats.py

The shell version remains for reference, but will eventually be
removed.

Most of the other scripts will similarly be converted over the coming
days.

Please don't commit updates to shell versions of scripts which have
already been converted; update the Python version instead.

--
Glynn Clements <glynn@gclements.plus.com>

G. Allegri wrote:

I didn't see the new versions of script. Wow, I've seen grass.py lib, very good!
Will all the scripts be converted?

Generally, yes.

There will be some exceptions for scripts which are disabled because
they don't currently work with 7.0 and it's unsure whether they will
be fixed or removed altogether.

Shell scripts which are only needed for compilation or testing are
likely to remain (the Makefiles need a shell anyhow).

If Init.sh stays, that will likely remain as separate Unix (shell) and
Windows (batch) versions, so that you can at least start GRASS if
Python isn't installed or isn't functional.

But it is intended that everything that's included with GRASS will be
usable on Windows without requiring MSys (i.e. no need for a shell or
Unix utilities).

--
Glynn Clements <glynn@gclements.plus.com>