Opened 6 years ago

Last modified 5 years ago

#3572 new defect

v.vect.stats creates cat & cat_ then fails

Reported by: simondedman Owned by: grass-dev@…
Priority: normal Milestone: 7.8.3
Component: Default Version: 7.4.0
Keywords: Cc:
CPU: x86-64 Platform: MSWindows CygWin

Description

Within QGis, GRASS processing toolbox element v.vect.stats counts point layer data within polygon areas layers & calculates statistics. If you want to calculate stats & counts for multiple fields in the points layer (e.g. you have data for various years) you have to repeat the process each time, selecting the layer and field, giving the resultant count & stats columns appropriate names, which produces a new polygon layer with the two new data fields appended, AND a field called 'cat'. If you use this new poly layer as the input for e.g. the next year's data, the output layer will already have 'cat' from the first run, so will create 'cat_'. The user likely doesn't care about these fields and there's no info presented during the process about what this is - it looks like a counter but I could very well be wrong. In any case: if you run the process a THIRD time, the code is defeated (presumably) because 'cat' is present so it tries 'cat_' which is also present, so it fails. Subsequently the user has to deduce that this is the problem with no help, then go to layer properties, source fields, edit, select cat & cat_, delete fields, unedit, save.

Proposal:

  1. have an option in the dialogue box to create 'cat' field (or not) and explain what it is. Turned on by default.
  2. Have cat field naming schema: cat0, cat1 etc, up to cat9999999 above which point it'll break the 10 character limit. Notwithstanding if you ran v.vect.stats 10 million times manually you'd experience the heat death of the universe before you hit the 10 character limit.

Change History (6)

in reply to:  description comment:1 by mmetz, 6 years ago

Replying to simondedman:

Within QGis, GRASS processing toolbox element v.vect.stats counts point layer data within polygon areas layers & calculates statistics. If you want to calculate stats & counts for multiple fields in the points layer (e.g. you have data for various years) you have to repeat the process each time, selecting the layer and field, giving the resultant count & stats columns appropriate names, which produces a new polygon layer with the two new data fields appended, AND a field called 'cat'. If you use this new poly layer as the input for e.g. the next year's data, the output layer will already have 'cat' from the first run, so will create 'cat_'. The user likely doesn't care about these fields and there's no info presented during the process about what this is - it looks like a counter but I could very well be wrong. In any case: if you run the process a THIRD time, the code is defeated (presumably) because 'cat' is present so it tries 'cat_' which is also present, so it fails. Subsequently the user has to deduce that this is the problem with no help, then go to layer properties, source fields, edit, select cat & cat_, delete fields, unedit, save.

Proposal:

  1. have an option in the dialogue box to create 'cat' field (or not) and explain what it is. Turned on by default.
  2. Have cat field naming schema: cat0, cat1 etc, up to cat9999999 above which point it'll break the 10 character limit. Notwithstanding if you ran v.vect.stats 10 million times manually you'd experience the heat death of the universe before you hit the 10 character limit.

The problem can be solved if QGIS uses v.out.ogr -s to skip export of GRASS category ID ('cat') attribute.

comment:2 by simondedman, 6 years ago

Thanks Markus. Am I right in thinking that QGis devs would have to code this switch into the GUI as an option? As it stands it seems the only call to v.out.ogr is to select the type, with a dropbown field that doesn't allow switches.

in reply to:  2 comment:3 by mmetz, 6 years ago

Replying to simondedman:

Thanks Markus. Am I right in thinking that QGis devs would have to code this switch into the GUI as an option?

I think it is safe to hard-code this switch (-s) in QGIS, and don't make it an option. While on it, the -m switch could also be hard-coded in QGIS.

comment:4 by simondedman, 6 years ago

Not make it an option i.e. general users probably don't need the cat column and therefore the -s switch could be on by default at all times? (Just want to make sure I understand correctly!)

What does the -m switch do? I was looking for v.out.ogr info in the v.vect.stats help & code but I guess I'm looking in the wrong places.

Thanks again.

in reply to:  4 comment:5 by mmetz, 6 years ago

Replying to simondedman:

Not make it an option i.e. general users probably don't need the cat column and therefore the -s switch could be on by default at all times? (Just want to make sure I understand correctly!)

Yes, because in the beginning (in the OGR vector) there is most probably no cat column, therefore there is no need to export it. The cat column is automatically generated by v.in.ogr when importing into GRASS.

What does the -m switch do? I was looking for v.out.ogr info in the v.vect.stats help & code but I guess I'm looking in the wrong places.

See G7:v.out.ogr. With the -m switch, multi-features (e.g.. multilinestrings, multipolygons) are exported from GRASS to OGR.

comment:6 by neteler, 5 years ago

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