[GRASS-dev] v.rast.stats fails with column_prefix='t'

The command

v.rast.stats map=SomeVector raster=SomeRaster column='t'

fails. Perhaps the line

<https://trac.osgeo.org/grass/browser/grass/trunk/scripts/v.rast.stats/v.rast.stats.py#L265&gt;

was simply meant to be something like:

for colname in colnames:
    variable = colprefix + '_' + colname
    print colname

?, Nikos

On Thu, Nov 19, 2015 at 1:28 PM, Nikos Alexandris <nik@nikosalexandris.net>
wrote:

The command

v.rast.stats map=SomeVector raster=SomeRaster column='t'

fails. Perhaps the line

How exactly does it fail?

<
https://trac.osgeo.org/grass/browser/grass/trunk/scripts/v.rast.stats/v.rast.stats.py#L265
>

was simply meant to be something like:

for colname in colnames:
    variable = colprefix + '_' + colname
    print colname

?, Nikos
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Nikos:

> The command
> v.rast.stats map=SomeVector raster=SomeRaster column='t'
> fails. Perhaps the line

Anna:

How exactly does it fail?

--%<---
v.info -c Test
INTEGER|cat
INTEGER|Id
CHARACTER|Name

v.rast.stats map=Test raster=LT51960282005221KIS00_B1 column='t'
Traceback (most recent call last):
  File "/osgeo/grass70/dist.x86_64-unknown-linux-gnu/scripts/v.rast.stats", line 306, in <module>
    main()
  File "/osgeo/grass70/dist.x86_64-unknown-linux-gnu/scripts/v.rast.stats", line 268, in main
    i = variables[variable]
KeyError: 'firsquartile'
--->%--

Strange, however, it does not fail always!?

Another example

--%<---
v.info -c test
INTEGER|cat

v.rast.stats map=test raster=test column_prefix='t'
--->%--

seems to work and gives

DOUBLE PRECISION|t_number
DOUBLE PRECISION|t_minimum
DOUBLE PRECISION|t_maximum
DOUBLE PRECISION|t_range
DOUBLE PRECISION|t_average
DOUBLE PRECISION|t_stddev
DOUBLE PRECISION|t_variance
DOUBLE PRECISION|t_coeff_va
DOUBLE PRECISION|t_sum
DOUBLE PRECISION|t_first_qu
DOUBLE PRECISION|t_median
DOUBLE PRECISION|t_third_qu
DOUBLE PRECISION|t_per90

Nikos

On Thu, Nov 19, 2015 at 8:53 PM, Nikos Alexandris
<nik@nikosalexandris.net> wrote:

Nikos:

> The command
> v.rast.stats map=SomeVector raster=SomeRaster column='t'
> fails. Perhaps the line

Anna:

How exactly does it fail?

--%<---
v.info -c Test
INTEGER|cat
INTEGER|Id
CHARACTER|Name

v.rast.stats map=Test raster=LT51960282005221KIS00_B1 column='t'
Traceback (most recent call last):
  File "/osgeo/grass70/dist.x86_64-unknown-linux-gnu/scripts/v.rast.stats", line 306, in <module>
    main()
  File "/osgeo/grass70/dist.x86_64-unknown-linux-gnu/scripts/v.rast.stats", line 268, in main
    i = variables[variable]
KeyError: 'firsquartile'

--> typo, should be firs*t*quartile I suppose.
But in my svn copy I don't find that.

Do you have local modifications? In the code I see "first_quartile"
with underscore.
Weird!

Markus

Nikos:

>> > The command
>> > v.rast.stats map=SomeVector raster=SomeRaster column='t'
>> > fails. Perhaps the line

Anna:

>> How exactly does it fail?

Nikos:

> --%<---
> v.info -c Test
> INTEGER|cat
> INTEGER|Id
> CHARACTER|Name
>
> v.rast.stats map=Test raster=LT51960282005221KIS00_B1 column='t'
> Traceback (most recent call last):
> File "/osgeo/grass70/dist.x86_64-unknown-linux-gnu/scripts/v.rast.stats", line 306, in <module>
> main()
> File "/osgeo/grass70/dist.x86_64-unknown-linux-gnu/scripts/v.rast.stats", line 268, in main
> i = variables[variable]
> KeyError: 'firsquartile'

Markus:

--> typo, should be firs*t*quartile I suppose.
But in my svn copy I don't find that.

Do you have local modifications?

Absolutely not.

In the code I see "first_quartile" with underscore.
Weird!

I did not find it either! It's not a typo. It is the result of .replace
(I did some examples).

Nikos

On Thu, Nov 19, 2015 at 2:53 PM, Nikos Alexandris <nik@nikosalexandris.net>
wrote:

Nikos:

> > The command
> > v.rast.stats map=SomeVector raster=SomeRaster column='t'
> > fails. Perhaps the line

Anna:

> How exactly does it fail?

--%<---
v.info -c Test
INTEGER|cat
INTEGER|Id
CHARACTER|Name

v.rast.stats map=Test raster=LT51960282005221KIS00_B1 column='t'
Traceback (most recent call last):
  File
"/osgeo/grass70/dist.x86_64-unknown-linux-gnu/scripts/v.rast.stats", line
306, in <module>
    main()
  File
"/osgeo/grass70/dist.x86_64-unknown-linux-gnu/scripts/v.rast.stats", line
268, in main
    i = variables[variable]
KeyError: 'firsquartile'
--->%--

Strange, however, it does not fail always!?

Another example

--%<---
v.info -c test
INTEGER|cat

v.rast.stats map=test raster=test column_prefix='t'
--->%--

seems to work and gives

DOUBLE PRECISION|t_number
DOUBLE PRECISION|t_minimum
DOUBLE PRECISION|t_maximum
DOUBLE PRECISION|t_range
DOUBLE PRECISION|t_average
DOUBLE PRECISION|t_stddev
DOUBLE PRECISION|t_variance
DOUBLE PRECISION|t_coeff_va
DOUBLE PRECISION|t_sum
DOUBLE PRECISION|t_first_qu
DOUBLE PRECISION|t_median
DOUBLE PRECISION|t_third_qu
DOUBLE PRECISION|t_per90

Nikos

Should be fixed in 66864. I still don't understand why it doesn't fail in
the other case though.

Anna

* Anna Petrášová <kratochanna@gmail.com> [2015-11-20 00:10:19 -0500]:

On Thu, Nov 19, 2015 at 2:53 PM, Nikos Alexandris <nik@nikosalexandris.net>
wrote:

> Nikos:
>
> > > The command
> > > v.rast.stats map=SomeVector raster=SomeRaster column='t'
> > > fails. Perhaps the line
>
> Anna:
>
> > How exactly does it fail?
>
> --%<---
> v.info -c Test
> INTEGER|cat
> INTEGER|Id
> CHARACTER|Name
>
> v.rast.stats map=Test raster=LT51960282005221KIS00_B1 column='t'
> Traceback (most recent call last):
> File
> "/osgeo/grass70/dist.x86_64-unknown-linux-gnu/scripts/v.rast.stats", line
> 306, in <module>
> main()
> File
> "/osgeo/grass70/dist.x86_64-unknown-linux-gnu/scripts/v.rast.stats", line
> 268, in main
> i = variables[variable]
> KeyError: 'firsquartile'
> --->%--
>
> Strange, however, it does not fail always!?
>
> Another example
>
> --%<---
> v.info -c test
> INTEGER|cat
>
> v.rast.stats map=test raster=test column_prefix='t'
> --->%--
>
> seems to work and gives
>
> DOUBLE PRECISION|t_number
> DOUBLE PRECISION|t_minimum
> DOUBLE PRECISION|t_maximum
> DOUBLE PRECISION|t_range
> DOUBLE PRECISION|t_average
> DOUBLE PRECISION|t_stddev
> DOUBLE PRECISION|t_variance
> DOUBLE PRECISION|t_coeff_va
> DOUBLE PRECISION|t_sum
> DOUBLE PRECISION|t_first_qu
> DOUBLE PRECISION|t_median
> DOUBLE PRECISION|t_third_qu
> DOUBLE PRECISION|t_per90
>
> Nikos
>
>
>

Should be fixed in 66864. I still don't understand why it doesn't fail in
the other case though.

Need to look closer -- no time. Yet, why use .replace for adding a prefix?

Nikos

On Fri, Nov 20, 2015 at 4:17 AM, Nikos Alexandris <nik@nikosalexandris.net>
wrote:

* Anna Petrášová <kratochanna@gmail.com> [2015-11-20 00:10:19 -0500]:

> On Thu, Nov 19, 2015 at 2:53 PM, Nikos Alexandris <
nik@nikosalexandris.net>
> wrote:
>
> > Nikos:
> >
> > > > The command
> > > > v.rast.stats map=SomeVector raster=SomeRaster column='t'
> > > > fails. Perhaps the line
> >
> > Anna:
> >
> > > How exactly does it fail?
> >
> > --%<---
> > v.info -c Test
> > INTEGER|cat
> > INTEGER|Id
> > CHARACTER|Name
> >
> > v.rast.stats map=Test raster=LT51960282005221KIS00_B1 column='t'
> > Traceback (most recent call last):
> > File
> > "/osgeo/grass70/dist.x86_64-unknown-linux-gnu/scripts/v.rast.stats",
line
> > 306, in <module>
> > main()
> > File
> > "/osgeo/grass70/dist.x86_64-unknown-linux-gnu/scripts/v.rast.stats",
line
> > 268, in main
> > i = variables[variable]
> > KeyError: 'firsquartile'
> > --->%--
> >
> > Strange, however, it does not fail always!?
> >
> > Another example
> >
> > --%<---
> > v.info -c test
> > INTEGER|cat
> >
> > v.rast.stats map=test raster=test column_prefix='t'
> > --->%--
> >
> > seems to work and gives
> >
> > DOUBLE PRECISION|t_number
> > DOUBLE PRECISION|t_minimum
> > DOUBLE PRECISION|t_maximum
> > DOUBLE PRECISION|t_range
> > DOUBLE PRECISION|t_average
> > DOUBLE PRECISION|t_stddev
> > DOUBLE PRECISION|t_variance
> > DOUBLE PRECISION|t_coeff_va
> > DOUBLE PRECISION|t_sum
> > DOUBLE PRECISION|t_first_qu
> > DOUBLE PRECISION|t_median
> > DOUBLE PRECISION|t_third_qu
> > DOUBLE PRECISION|t_per90
> >
> > Nikos
> >
> >
> >
>
> Should be fixed in 66864. I still don't understand why it doesn't fail in
> the other case though.

Need to look closer -- no time. Yet, why use .replace for adding a prefix?

At that point is actually removing the prefix. There is a better way to
fix it, but this was quick and easy fix, hopefully effective.

Anna

Nikos