Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having some doubts concerning the layer mechanism.

Creating a new layer (ie a new connection between a vector and a DB table), I've imported a vector (rivers) through, then I've cloned the original table:

db.copy from_table=rivers to_table=rivers_clone

I've created a new connection:

v.db.connect map=rivers table=rivers_clone layer=2

At this point I supposed that the last command had created all the needed structures and fields for the new layer (2), but if I print the categories:

v.category input=rivers layer=2 option=print

no categories are displayed (while they are listed if I choose layer 1).

Question: I thought that a new connection used the same vector categories, but it seems I was wrong. How to make the layer 2 use the same vector categories from layer 1?

share|improve this question
Please open two questions instead of asking everything in one. I'll remove the second question. Please put it into a new topic so they can be answered separately. – underdark Nov 20 '11 at 20:06
I will open a second question if you wish but the two questions were strictly related because they refer to the same problem: managing a new layer. – giohappy Nov 20 '11 at 23:20
Further, while using v.category , the new tables names are being assigned as follows: schema_name.map_name1_schema_name.map_name2 Please notice the two dots. Error message says " cross-database reference not allowed " and tables are not created. – user5009 Dec 2 '11 at 15:55

I've solved my needs about the creation of a new layer, but I feel that the mechanism a bit counter-intuitive. It seems that creating a new layer, an intemediary vector is unavodidable

v.category input=rivers output=rivers_tmp layer=2
g.remove vect=rivers
g.rename vect=rivers_tmp,rivers

Directly creating a new connection on a new layer produces the new layer, but the categories are not attached:

v.db.connect map=rivers table=rivers_clone layer=2

and the vector seems to have a new layer, but it cannot be used. I see the same results if I create a new layer through the wxGUI (vector attributes window -> new layer). A new layer is shown, but it cannot be used (eg cannot be displayed). I will open a ticket on this.


share|improve this answer
I think too that requiring an intermediate vector map, as for adding a new layer, is not intuitive. – Nikos Alexandris May 17 '13 at 13:02
You need to populate the "cat" column in a newly added layer with rivers_tmp (or rivers after renaming) option=cat layer=2 col=cat. Also, pay some attention to the type= parameter -- for areas (=boundary + centroid) you need to use type=centroid. – Nikos Alexandris May 17 '13 at 13:04
And because I was too fast (1st, this is an old question, 2nd you want to use the cats from layer 1): I guess it is not that easy after all! – Nikos Alexandris May 17 '13 at 13:15
O-K, the correct sequence is to transfer/add layer categories using v.category with option=transfer and then, (re-)connect the attribute table of interest in the layer of interest, e.g. by using v.db.connect and layer=2. Check out this grass-dev thread. – Nikos Alexandris May 17 '13 at 14:30

As an explanation of the mechanism: categories are stored in both geometry and attributes (otherwise, how to match them...). If you operate with db.copy, then v.db.connect, the adding part of categories is yet missing for layer2. Hence no real connection. One could argue that v.db.connect and not v.category (with "add") should do the job - in case please open an enhancement ticket for this.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.