<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 3, 2015 at 3:11 PM, Moritz Lennert <span dir="ltr"><<a href="mailto:mlennert@club.worldonline.be" target="_blank">mlennert@club.worldonline.be</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 03/04/15 14:42, Paulo van Breugel wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have a shapefile with overlapping polygons. After importing I thus<br>
end up with a vector layer with for each unique polygon (feature) one<br>
or more category values (i.e., one to many relationship).<br>
<br>
Now I want to create a second attribute table linked to layer 2 with<br>
a cat column with for each polygon (for each internal feature id) an<br>
 unique category.<br>
<br>
Next, I want to use this to count the number of categories linked to<br>
 each unique feature id.<br>
</blockquote>
<br></span>
If you have overlapping polygons, after running v.in.ogr your map<br>
already has layer 2 categories which represent for each feature where<br>
there is overlap the number of overlapping polygons in that space. IIUC,<br>
this is what you are looking for, or ?<br></blockquote><div><br></div><div>Yes, sorry, I was just about to write that this is indeed the case; you were just ahead of me. In my initial attempt something went wrong, I should have checked better, but was focused on getting a column with the unique values per polygon (which as you write below does not seem to work?).<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<br>
I know this has been asked and answered before, but the solutions<br>
(copied below) do not work for me.<br>
<br>
This worked, I think, in GRASS 6, but it doesn't in G7 because a new<br>
 vector map needs to be defined<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
/v.category op=add layer=2 type=centroid/ /v.to.db type=centroid<br>
option=cat/<br>
</blockquote></blockquote>
<br>
And what is the problem with defining a new vector map. This new vector<br>
map will contain all existing layers plus the new layer. But in this<br>
case it should be:<br>
<br>
v.category map op=add layer=3 type=centroid out=map2<br>
<br>
You can then create a table for layer 3 with v.db.addtable:<br>
<br>
v.db.addtable map2 layer=3 columns="cat2 integer"<br>
<br>
and should be able to load the cat values of layer 2 into the table of layer 3 with v.to.db,</blockquote><div><br></div><div>I knew (ok, I hoped) this should be simple. Thanks<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> but this does not seem to work at the moment:<br>
<br>
v.to.db map22 layer=3 query_layer=2 op=cat columns=cat2<br>
<br>
(there seems to be confusion between map layers, but I don't have time to check. Definitely worth a bug report.)<br></blockquote><div><br></div><div>I'll create one <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
The below does not create an attribute table with unique attributes<br></span>
for each unique feature. /> v.in.ogr dsn=test_polygones.shp<br>
out=polygons<br>
v.db.addtable polygons layer=2<br>
</blockquote>
> v.category polygons option=add<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
layer=2 type=centroid out=polygons_tmp<br>
</blockquote>
v.to.db polygons_tmp<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
type=centroid option=cat layer=2 col=cat/<br>
</blockquote></blockquote>
<br>
For those features where there is overlap, this will not create new categories, but upload to the table the existing category which is the number of overlapping features.<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>OK, I was confused here, thanks for the explanation <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
<br>
<br>
<br>
Moritz<br>
</font></span></blockquote></div><br></div></div>