Opened 11 years ago
Closed 11 years ago
#2121 closed enhancement (fixed)
v.rast.stats: allow choice of statistics
Reported by: | mlennert | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.0.0 |
Component: | Vector | Version: | svn-trunk |
Keywords: | v.rast.stats | Cc: | |
CPU: | Unspecified | Platform: | Unspecified |
Description
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:
INTEGER|B5_n DOUBLE PRECISION|B5_min DOUBLE PRECISION|B5_max DOUBLE PRECISION|B5_range DOUBLE PRECISION|B5_mean DOUBLE PRECISION|B5_stddev DOUBLE PRECISION|B5_varianc DOUBLE PRECISION|B5_cf_var DOUBLE PRECISION|B5_sum
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.
Moritz
Change History (14)
comment:1 by , 11 years ago
follow-ups: 3 4 comment:2 by , 11 years ago
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?
comment:3 by , 11 years ago
Replying to 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.
follow-up: 5 comment:4 by , 11 years ago
Replying to 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
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 ?
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?
Sounds reasonable to me.
Moritz
follow-up: 6 comment:5 by , 11 years ago
Replying to 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 (it also solve another problem with DBF driver).
Sounds reasonable to me.
I wait other dev's comments before make these changes
Moritz
Luca
follow-up: 9 comment:6 by , 11 years ago
Replying to lucadelu:
Replying to 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.
Moritz
follow-ups: 8 10 comment:7 by , 11 years ago
Hi Moritz,
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...
Matteo
comment:8 by , 11 years ago
Replying to 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:
http://lists.osgeo.org/pipermail/grass-dev/2013-October/thread.html#65948
follow-ups: 12 13 comment:9 by , 11 years ago
Replying to 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.
No objections were done for remove the e flag and add the methods to method option, so I start to implement it
Moritz
Luca
follow-up: 11 comment:10 by , 11 years ago
comment:11 by , 11 years ago
Replying to lucadelu:
Replying to 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.
Actually AFAIK, there was no agreement, yet, on what was preferred. Vaclav actually argued for 'mean' instead of 'average' 1.
comment:12 by , 11 years ago
Replying to lucadelu:
Replying to 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.
Seems to work nicely, thanks !
Moritz
comment:13 by , 11 years ago
comment:14 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Ticket completed, closing it.
Please reopen if needed
Trac didn't like my use of the pipe character as OR operator, so "variance stddev" should read "variance OR stddev".