[GRASS-user] Question about layers and categories

Hi,

I hope the questions to come are not too stupid, but I need some help
about some points that remain to me unclear about vector layers &
category management :

Let's take the case of a point vector produced by v.to.point module. You
know this command creates a 2 layers vector, consisting in:
- 2 distinct tables,
- 2 sets of categories.

The first point is when removing a layer, categories associated with
this layer /remain/ attached to the geometry. Should I purge categories
from the layer I want to delete (with v.category command) prior to
remove layer ?

When I remove layer 1, trying to query layer 2 points in wxGUI display
window, the result appears in the terminal but the classical pop-up does
not rise (whatever "layer" parameter in d.vect).

Then I try to change layer "2" to number "1" (v.category with
option=chlayer layer=2,1). The command performs without apparent
problem, but v.to.db -p tells me the expected layer 1 is still number
2...

In a word, all this is very confusing.
Could anyone help me to point at what is going wrong, either in my
understanding of attribute handling or in possible issues in the
commands I use (v.to.db, v.category)

Thanks,
Vincent

On Thu, Apr 4, 2013 at 6:24 PM, Vincent Bain <bain@toraval.fr> wrote:

Hi,

I hope the questions to come are not too stupid, but I need some help
about some points that remain to me unclear about vector layers &
category management :

Let's take the case of a point vector produced by v.to.point module. You
know this command creates a 2 layers vector, consisting in:
- 2 distinct tables,
- 2 sets of categories.

The first point is when removing a layer, categories associated with
this layer /remain/ attached to the geometry.

How did you remove a layer? If you used v.db.connect -d or
v.db.droptable, then you deleted the link of an attribute table to a
layer. As you observed, categories for this layer will remain attached
to the geometry as reported by v.category op=report.

Should I purge categories
from the layer I want to delete (with v.category command) prior to
remove layer ?

Do you want to remove the attribute table or the categories attached
to the geometry objects?

Usually it does not harm to have categories attached to geometries in
multiple layers.

When I remove layer 1, trying to query layer 2 points in wxGUI display
window, the result appears in the terminal but the classical pop-up does
not rise (whatever "layer" parameter in d.vect).

The wxGUI query ignores d.vect options and will (should) report
anything found in any layer.

Then I try to change layer "2" to number "1" (v.category with
option=chlayer layer=2,1). The command performs without apparent
problem, but v.to.db -p tells me the expected layer 1 is still number
2...

Can you post the output of v.to.db -p? I did a quick test and v.to.db
does not tell me anything about an expected layer number...

In a word, all this is very confusing.
Could anyone help me to point at what is going wrong, either in my
understanding of attribute handling or in possible issues in the
commands I use (v.to.db, v.category)

In short, categories and associated layer numbers are stored with the
geometry. Category numbers for a given layer are used as key for the
link to an attribute table for the given layer. IOW, you need a vector
geometry object with a category number for a given layer and that
category number existing in the key column of the corresponding
attribute table in order to have attributes linked to the given object
and layer.

HTH,

Markus M

Thanks,
Vincent

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Thank you Markus for your reply.
The least we can say is that my message was not very well stated, in
cause it reveals several questions... eventhough I was convinced to be
clear-minded about vector/database grass model !

So, let's put aside wxGUI-related questions. And go on with an example :
        v.to.points -v input=project output=test type=line

The result is a point vector with 2 layers :
        v.db.connect -p map=test
                Vector map <test@vincent> is connected by:
                layer <1> table <test_1> in database
                </home/vincent/Pro/toraval/cauterets2013/L2e/vincent/sqlite.db> through driver <sqlite> with key <cat>
                layer <2> table <test_2> in database
                </home/vincent/Pro/toraval/cauterets2013/L2e/vincent/sqlite.db> through driver <sqlite> with key <cat>

As I need to work with data from layer 2 only, I want to purge layer 1
(i.e. (i) its symbolic link to table test_1, (ii) the set of categories
attached to layer 1, and secondarily table test_1, but I can perform it
at the sqlite3 prompt, no problem).
Your comment "Usually it does not harm to have categories attached to
geometries in multiple layers" suggests me to leave these unused
categories in place, isn't it ?

So I run
        v.db.connect -d layer=1 map=test
        
and we have :
        v.db.connect -p map=test
                Vector map <test@vincent> is connected by:
                layer <2> table <test_2> in database
                </home/vincent/Pro/toraval/cauterets2013/L2e/vincent/sqlite.db> through driver <sqlite> with key <cat>

Practically ok, it can do the job. But all in all, what I am /unable/ to
properly do is to turn this layer <2> into a new layer <1> (and for that
I guess I first have to get rid of the former layer <1> categories).
Maybe it's a fancy of the mind but it would be rewarding for me to
succeed in it :wink:

Now, what about wxGUI ?
I agree with your comment "The wxGUI query ignores d.vect options and
will (should) report anything found in any layer." : the query tool
works quite well if you refer to results returned to command console,
but when no data is retrieved from layer <1>, the "update attributes"
popup does not appear, in other words, if you want to change layer <2>
attributes on the fly from the map display... you can't.

Thanks for your clarifications in the end, it confirms my initial idea
about this stuff.

Vincent.

On 04/04/13 22:39, Vincent Bain wrote:

Thank you Markus for your reply.
The least we can say is that my message was not very well stated, in
cause it reveals several questions... eventhough I was convinced to be
clear-minded about vector/database grass model !

So, let's put aside wxGUI-related questions. And go on with an example :
         v.to.points -v input=project output=test type=line

The result is a point vector with 2 layers :
         v.db.connect -p map=test
                 Vector map<test@vincent> is connected by:
                 layer<1> table<test_1> in database
                 </home/vincent/Pro/toraval/cauterets2013/L2e/vincent/sqlite.db> through driver<sqlite> with key<cat>
                 layer<2> table<test_2> in database
                 </home/vincent/Pro/toraval/cauterets2013/L2e/vincent/sqlite.db> through driver<sqlite> with key<cat>

As I need to work with data from layer 2 only, I want to purge layer 1
(i.e. (i) its symbolic link to table test_1, (ii) the set of categories
attached to layer 1, and secondarily table test_1, but I can perform it
at the sqlite3 prompt, no problem).
Your comment "Usually it does not harm to have categories attached to
geometries in multiple layers" suggests me to leave these unused
categories in place, isn't it ?

So I run
         v.db.connect -d layer=1 map=test

v.db.droptable does i and iii for you in one go.
for ii:
v.category op=del layer=1

Now, what about wxGUI ?
I agree with your comment "The wxGUI query ignores d.vect options and
will (should) report anything found in any layer." : the query tool
works quite well if you refer to results returned to command console,
but when no data is retrieved from layer<1>, the "update attributes"
popup does not appear, in other words, if you want to change layer<2>
attributes on the fly from the map display... you can't.

cf [1], but also [2]

Which version of GRASS are you working in ?

Moritz

[1] http://trac.osgeo.org/grass/ticket/1606
[2] https://trac.osgeo.org/grass/ticket/1703

Hello Mortiz,
your reply helped me much. Removing/Reassigning layers is a matter of
several steps :
-drop previous layer definition, optionally drop related table;
-delete unused layer categories;
-change remaining categories layer assignment (it is the step I
misunderstood till then );
-define new layer.

This operation is perhaps not so "exotic" considering the wxGUI update
attribute issue.

cf [1], but also [2]

Sorry, I neglected to watch for open tickets.

Which version of GRASS are you working in ?

GRASS version:
6.4.3svn
GRASS SVN Revision:
55280
GIS Library Revision: 50937
(2012-02-25)
GDAL/OGR:
1.8.1
PROJ4: Rel. 4.7.1, 23 September
2009
Python:
2.6.6
wxPython:
2.8.10.1
Platform: Linux-2.6.32-5-amd64-x86_64-with-debian-6.0.7

VB.

On 05/04/13 12:03, Vincent Bain wrote:

Hello Mortiz,
your reply helped me much. Removing/Reassigning layers is a matter of
several steps :
-drop previous layer definition, optionally drop related table;

Please note: as MarkusM has already mentioned, you cannot drop a "layer definition". You can drop the definition of a connection of a given layer in a vector map to an attribute table. Whether or not a given layer "exists" only depends on whether there are category values defined for that layer for at least one feature in the map.

Have you read "Vector object categories and attribute management" -> "layers" on [1]. If not please do so and tell us if we can improve the explanation.

[1] http://grass.osgeo.org/grass64/manuals/vectorintro.html

-delete unused layer categories;

This is probably the closest you can get to "deleting a layer".

-change remaining categories layer assignment (it is the step I
misunderstood till then );
-define new layer.

This operation is perhaps not so "exotic" considering the wxGUI update
attribute issue.

[...]

Which version of GRASS are you working in ?

GRASS version:
6.4.3svn
GRASS SVN Revision:
55280

Then you should at least be able to query vector maps with several layers and get a result in the command console. You do not get the update dialog, though. Something to be worked on for grass7 I think.

Moritz

Le vendredi 05 avril 2013 à 12:37 +0200, Moritz Lennert a écrit :

On 05/04/13 12:03, Vincent Bain wrote:
> Hello Mortiz,
> your reply helped me much. Removing/Reassigning layers is a matter of
> several steps :
> -drop previous layer definition, optionally drop related table;

Please note: as MarkusM has already mentioned, you cannot drop a "layer
definition". You can drop the definition of a connection of a given
layer in a vector map to an attribute table. Whether or not a given
layer "exists" only depends on whether there are category values defined
for that layer for at least one feature in the map.

Ok, I was thinking "drop the layer<->table connection".

Have you read "Vector object categories and attribute management" ->
"layers" on [1]. If not please do so and tell us if we can improve the
explanation.

I did again, it was necessary. May it be a good improvment to adjoin
some graphical material to make things faster to understand ?

Then you should at least be able to query vector maps with several
layers and get a result in the command console. You do not get the
update dialog, though. Something to be worked on for grass7 I think.

nice,

Thank you again,
Vincent.

On 05/04/13 12:59, Vincent Bain wrote:

Le vendredi 05 avril 2013 à 12:37 +0200, Moritz Lennert a écrit :

Have you read "Vector object categories and attribute management" ->
"layers" on [1]. If not please do so and tell us if we can improve the
explanation.

I did again, it was necessary. May it be a good improvment to adjoin
some graphical material to make things faster to understand ?

Anything that helps people understand layers is more than welcome. And it's good to have input from people who see this with fresh eyes.

Moritz

Anything that helps people understand layers is more than welcome. And
it's good to have input from people who see this with fresh eyes.

Will try to propose sth soon.

V.