Opened 11 years ago

Last modified 6 years ago

#2113 new defect

v.report reports wrong categories after deleting/merging features in the digitizer

Reported by: hcho Owned by: grass-dev@…
Priority: major Milestone: 7.6.2
Component: Python Version: svn-trunk
Keywords: category Cc:
CPU: All Platform: All

Description

After deleting/merging features in the digitizer, the number of categories in the vector map becomes less than the number of rows in the attribute table. For example, I originally had 130 features, 130 categories, and 130 rows in a vector map. I deleted and merged some features and now I have one feature that has 43 categories, and still 130 rows in the table.

v.category main_stream option=print shows these 43 cats: 128/109/123/125/112/104/108/113/107/102/103/96/98/99/130/129/21/22/23/20/18/87/85/86/68/84/69/37/39/40/42/25/35/24/67/83/4/2/16/17/9/10/6

Now, if I use v.report map=main_stream option=length, I get exactly 43 lines, but they're not the correct 43 categories. They're simply from 1 to 43. Also, if I use the percent unit, even if all these records represent the same geometry, percent calculations are not all 100%, but 100/43%, which I understand why this happens, but doesn't make sense.

I tried to fix the first problem with the following patch:

127c127,129
<       records3 = [r1 + r2[1:] for r1, r2 in zip(records1, records2)]
---
>       records3 = []
>       for r2 in records2:
>               records3.append(filter(lambda r1: r1[0] == r2[0], records1)[0] + r2[1:])

But, this is a partial fix because it doesn't fix the percent problem and doesn't handle the if not colnames case where it uses v.category.

It would be great if experienced python developers can take a look at these issues.

The following is a simple version of these problems: Currently, v.report main_stream option=length reports:

cat|value|length
1|3781|80418.2088197
2|3781|80418.2088197
3|3781|80418.2088197
4|3781|80418.2088197
5|3781|80418.2088197

But, I think this command should report the following because main_stream's only feature has 10/4/6/2/9:

cat|value|length
2|3781|80418.2088197
4|3781|80418.2088197
6|3781|80418.2088197
9|3781|80418.2088197
10|3781|80418.2088197

Also, v.report main_stream option=length units=percent shows

cat|value|length
1|3781|20.0
2|3781|20.0
3|3781|20.0
4|3781|20.0
5|3781|20.0

but this map has only one line geometry with five cats.

Thanks. Huidae

Change History (5)

comment:1 by hcho, 11 years ago

CPU: UnspecifiedAll
Keywords: category added

Or maybe, this is better because there is no way to differentiate different features from different categories in one feature?

cat|value|length
2,4,6,9,10|3781|80418.2088197

I'm not sure...

comment:2 by martinl, 9 years ago

Milestone: 7.0.07.0.5

comment:3 by neteler, 8 years ago

Milestone: 7.0.57.0.6

comment:4 by neteler, 7 years ago

Milestone: 7.0.67.0.7

comment:5 by martinl, 6 years ago

Milestone: 7.0.77.6.2
Note: See TracTickets for help on using tickets.