#2121: v.rast.stats: allow choice of statistics
--------------------------+-------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
Type: enhancement | Status: new
Priority: normal | Milestone: 7.0.0
Component: Vector | Version: svn-trunk
Keywords: v.rast.stats | Platform: Unspecified
Cpu: Unspecified |
--------------------------+-------------------------------------------------
It would be convenient if v.rast.stats allowed a choice of statistics that
one wants to upload to the attribute table. Currently, it creates 9
columns:
a series of which can actually be derived from others (mean, range, sttdev
|| variance, coefficient of variation), meaning that only 5 are really
needed (n, min, max, variance || stddev, sum).
So, at least we could limit the uploaded statistics to those 5, or even
allow choice of statistics through a parameter.
Replying to [comment:2 lucadelu]:
> I added a ''method'' option to choose the methods to save in the
attribute table in r58726.
>
> I would like also to remove ''-e'' flag and add the methods calculated
by extended statistics to the ''method'' 's options, what do you think?
Please try r58727, in previous version there was a small bug.
Replying to [comment:2 lucadelu]:
> I added a ''method'' option to choose the methods to save in the
attribute table in r58726.
This is great, thanks ! Just one problem: it fails at lines 255-256 with
the dbf driver as colnames get truncated, but your variable names are
full, and so
>
> This is great, thanks ! Just one problem: it fails at lines 255-256 with
the dbf driver as colnames get truncated, but your variable names are
full, and so
>
>
> {{{
> variable = colname.replace("%s_" % colprefix, '')
> i = variables[variable]
> }}}
>
> leads to a key error since 'variable' does not exist in 'variables'. A
solution might be to use a dictionary linking variable names to colnames ?
>
Yes I fixed it using dictionary, try r58728 (it also solve another problem
with DBF driver).
>
> Sounds reasonable to me.
>
I wait other dev's comments before make these changes
Replying to [comment:5 lucadelu]:
> Replying to [comment:4 mlennert]:
>
> >
> > This is great, thanks ! Just one problem: it fails at lines 255-256
with the dbf driver as colnames get truncated, but your variable names are
full, and so
> >
> >
> > {{{
> > variable = colname.replace("%s_" % colprefix, '')
> > i = variables[variable]
> > }}}
> >
> > leads to a key error since 'variable' does not exist in 'variables'. A
solution might be to use a dictionary linking variable names to colnames ?
> >
>
> Yes I fixed it using dictionary, try r58728
Yup, works great now.
> (it also solve another problem with DBF driver).
Great, I had just stumbled upon that while testing !
Now, one more issue: since recently (r57999), there is the possibility to
abbreviate option values, but this does not seem to work here:
{{{
v.rast.stats blks raster=elevation column=elev
method=mini,maxi,mean,stddev -c
Processing data (2535 categories)...
Traceback (most recent call last):
File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-unknown-
linux-gnu/scripts/v.rast.stats", line 295, in <module>
main()
File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-unknown-
linux-gnu/scripts/v.rast.stats", line 261, in main
i = variables[variable]
KeyError: 'mini'
}}}
I don't know exactly what's needed to make this work, but it would be nice
if it did.
> So, at least we could limit the uploaded statistics to those 5, or even
allow choice of statistics through a parameter.
>
> Moritz
I would preserve the (singol) choice of all the 9 statistics without
dropping the extended ones.
Furthermore, just a suggestion: the "average" statistic is called
"average" in r.series and "mean" in v.rast.stats. It would be great if
someone could manage to unify the terminology...
Replying to [comment:7 matmar]:
...
> Furthermore, just a suggestion: the "average" statistic is
> called "average" in r.series and "mean" in v.rast.stats.
> It would be great if someone could manage to unify the terminology...
Right. For a discussion on this, see this email and following:
>
> Now, one more issue: since recently (r57999), there is the possibility
to abbreviate option values, but this does not seem to work here:
>
>
> {{{
> v.rast.stats blks raster=elevation column=elev
method=mini,maxi,mean,stddev -c
> Processing data (2535 categories)...
> Traceback (most recent call last):
> File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-unknown-
linux-gnu/scripts/v.rast.stats", line 295, in <module>
> main()
> File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-unknown-
linux-gnu/scripts/v.rast.stats", line 261, in main
> i = variables[variable]
> KeyError: 'mini'
> }}}
>
> I don't know exactly what's needed to make this work, but it would be
nice if it did.
>
fixed in r58731, I just check the long name and set it instead the
abbreviate one.
No objections were done for remove the ''e'' flag and add the methods to
''method'' option, so I start to implement it
>
> Furthermore, just a suggestion: the "average" statistic is called
"average" in r.series and "mean" in v.rast.stats. It would be great if
someone could manage to unify the terminology...
>
Replying to [comment:10 lucadelu]:
> Replying to [comment:7 matmar]:
>
> >
> > Furthermore, just a suggestion: the "average" statistic is called
"average" in r.series and "mean" in v.rast.stats. It would be great if
someone could manage to unify the terminology...
> >
>
> fixed in r58731.
Replying to [comment:9 lucadelu]:
> Replying to [comment:6 mlennert]:
>
> >
> > Now, one more issue: since recently (r57999), there is the possibility
to abbreviate option values, but this does not seem to work here:
> >
> >
> > {{{
> > v.rast.stats blks raster=elevation column=elev
method=mini,maxi,mean,stddev -c
> > Processing data (2535 categories)...
> > Traceback (most recent call last):
> > File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-unknown-
linux-gnu/scripts/v.rast.stats", line 295, in <module>
> > main()
> > File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-unknown-
linux-gnu/scripts/v.rast.stats", line 261, in main
> > i = variables[variable]
> > KeyError: 'mini'
> > }}}
> >
> > I don't know exactly what's needed to make this work, but it would be
nice if it did.
> >
>
> fixed in r58731, I just check the long name and set it instead the
abbreviate one.