<div dir="ltr"><div>Dear all, <br></div><div><br></div><div>thanks for the answers... <br></div><div><br></div><div>@Madi, I know, but that's how I got the data from a colleague using SaTScan to get cluster sizes. <br></div><div><br></div><div>So, these "clusters" are 3, they are represented by circular areas and 2 of them overlap, and it is just fine that they overlap. I just want one centroid per area to be able to get one value per original area. <br></div><div><br></div><div>I tested your solution, @Micha (thanks much for your time!), but it gives me 4 values, and I need 3. Moreover, I can no longer recognize which polygon is which since v.db.select for layer 3 reports cats from 1 to 4, but d.vect shows something different (I'd assume 2/3 has become 4?). See screenshot below. <br></div><div> <br></div><div>So, is it possible somehow to keep my 3 original polygons? And how can I get raster values for my original 3 polygons in GRASS? Or is it that this is not allowed by topology?</div><div><br></div><div>best,</div><div>Vero<br></div><div><br></div><div><div><img src="cid:ii_jvpy8zr10" alt="image.png" style="margin-right: 0px;" width="542" height="283"><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El mié., 15 may. 2019 a las 12:04, Micha Silver (<<a href="mailto:tsvibar@gmail.com">tsvibar@gmail.com</a>>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
    
  
  <div style="direction:ltr" bgcolor="#FFFFFF">
    <br>
    <div class="gmail-m_1447804715120165781moz-cite-prefix">On 15/05/2019 0:46, Veronica Andreo
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div dir="ltr">
          <div>Hi all,</div>
          <div><br>
          </div>
          <div>I was working today with a very simple vector map which
            corresponds to clusters (circular polygons) that overlap and
            it is just fine that they overlap. So, i received a
            shapefile with 3 of these clusters. Two of them overlaped.
            When I import them into GRASS with v.import I get an extra
            centroid and area where 2 of the polygons overlap. <br>
          </div>
          <div><br>
          </div>
          <div>Problem arises when I want to query a raster map with
            those polygons since originally the attribute table
            contained only 3 polygons (which is just fine). However,
            v.what.rast will only upload values for 2 of those three
            polygons because it finds 2 centroids with the same
            category, AFAIU.</div>
          <div><br>
          </div>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
    <p>Here's how to get the raster values for all polygons (including
      those which are overlaps). It involves the somewhat non-intuitive
      process of creating another layer. I imported a simple polygon
      shapefile with three overlapping areas. Here are the categories:</p>
    <p><br>
    </p>
    <p><tt>micha@TP480:~$ v.category polys opt=report</tt><tt><br>
      </tt><tt>Layer/table: 1/polys</tt><tt><br>
      </tt><tt>type       count        min        max</tt><tt><br>
      </tt><tt>point          0          0          0</tt><tt><br>
      </tt><tt>line           0          0          0</tt><tt><br>
      </tt><tt>boundary       0          0          0</tt><tt><br>
      </tt><tt>centroid      12          1          3</tt><tt><br>
      </tt><tt>area           0          0          0</tt><tt><br>
      </tt><tt>face           0          0          0</tt><tt><br>
      </tt><tt>kernel         0          0          0</tt><tt><br>
      </tt><tt>all           12          1          3</tt><tt><br>
      </tt><tt>Layer: 2</tt><tt><br>
      </tt><tt>type       count        min        max</tt><tt><br>
      </tt><tt>point          0          0          0</tt><tt><br>
      </tt><tt>line           0          0          0</tt><tt><br>
      </tt><tt>boundary       0          0          0</tt><tt><br>
      </tt><tt>centroid       4          2          3</tt><tt><br>
      </tt><tt>area           0          0          0</tt><tt><br>
      </tt><tt>face           0          0          0</tt><tt><br>
      </tt><tt>kernel         0          0          0</tt><tt><br>
      </tt><tt>all            4          2          3</tt></p>
    <p><br>
    </p>
    <p>So, as you found, you get two layers, with all original areas
      split up at overlaps in layer 1, and just the overlap areas in
      layer 2.  Now add a third layer, with new category values
      (option=add):</p>
    <p><br>
    </p>
    <p><tt>micha@TP480:~$ v.category polys option=add layer=3
        out=polys_3layers</tt></p>
    <p><tt>Layer/table: 1/polys_3layers</tt><tt><br>
      </tt><tt>type       count        min        max</tt><tt><br>
      </tt><tt>point          0          0          0</tt><tt><br>
      </tt><tt>line           0          0          0</tt><tt><br>
      </tt><tt>boundary       0          0          0</tt><tt><br>
      </tt><tt>centroid      12          1          3</tt><tt><br>
      </tt><tt>area           0          0          0</tt><tt><br>
      </tt><tt>face           0          0          0</tt><tt><br>
      </tt><tt>kernel         0          0          0</tt><tt><br>
      </tt><tt>all           12          1          3</tt><tt><br>
      </tt><tt>Layer: 2</tt><tt><br>
      </tt><tt>type       count        min        max</tt><tt><br>
      </tt><tt>point          0          0          0</tt><tt><br>
      </tt><tt>line           0          0          0</tt><tt><br>
      </tt><tt>boundary       0          0          0</tt><tt><br>
      </tt><tt>centroid       4          2          3</tt><tt><br>
      </tt><tt>area           0          0          0</tt><tt><br>
      </tt><tt>face           0          0          0</tt><tt><br>
      </tt><tt>kernel         0          0          0</tt><tt><br>
      </tt><tt>all            4          2          3</tt><tt><br>
      </tt><tt>Layer: 3</tt><tt><br>
      </tt><tt>type       count        min        max</tt><tt><br>
      </tt><tt>point          0          0          0</tt><tt><br>
      </tt><tt>line           0          0          0</tt><tt><br>
      </tt><tt>boundary       0          0          0</tt><tt><br>
      </tt><tt>centroid       7          1          7</tt><tt><br>
      </tt><tt>area           0          0          0</tt><tt><br>
      </tt><tt>face           0          0          0</tt><tt><br>
      </tt><tt>kernel         0          0          0</tt><tt><br>
      </tt><tt>all            7          1          7</tt></p>
    <p><br>
    </p>
    <p>This gives me three layers, and the new layer 3 has individual
      cat values for each polygon. So I'm ready to add a database table
      and column to that layer for the raster value, and then run
      v.what.rast:</p>
    <br>
    <p><tt>micha@TP480:~$ v.db.addtable polys_3layers layer=3
        columns="rast_value DOUBLE"</tt></p>
    <p><tt>micha@TP480:~$ v.what.rast polys_3layers rast=dem_4m
        column=rast_value layer=3 type=centroid</tt><tt><br>
      </tt><tt>Reading features from vector map...</tt><tt><br>
      </tt><tt>Update vector attributes...</tt><tt><br>
      </tt><tt> 100%</tt><tt><br>
      </tt><tt>v.what.rast complete. 7 records updated.</tt><tt><br>
      </tt><tt>micha@TP480:~$ v.db.select polys_3layers layer=3</tt><tt><br>
      </tt><tt>cat|rast_value</tt><tt><br>
      </tt><tt>1|488.3321</tt><tt><br>
      </tt><tt>2|492.7044</tt><tt><br>
      </tt><tt>3|481.2958</tt><tt><br>
      </tt><tt>4|498.173</tt><tt><br>
      </tt><tt>5|501.3336</tt><tt><br>
      </tt><tt>6|493.2202</tt><tt><br>
      </tt><tt>7|471.7223</tt><br>
      <br>
    </p>
    <p>Does this help?<br>
    </p>
    <p><br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite">
      <div dir="ltr">
        <div dir="ltr">
          <div>I tried with <span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr"><br>
            </span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr"><br>
            </span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr">v.clean input=clusters
              output=clusters_clean1 tool=break,rmdupl,rmsa,rmdac<br>
            </span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr"><br>
            </span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr">and <br>
            </span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr"><span id="gmail-m_1447804715120165781gmail-:4u.co" class="gmail-m_1447804715120165781gmail-tL8wMe gmail-m_1447804715120165781gmail-EMoHub" style="text-align:left" dir="ltr"><br>
              </span></span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr"><span id="gmail-m_1447804715120165781gmail-:4u.co" class="gmail-m_1447804715120165781gmail-tL8wMe gmail-m_1447804715120165781gmail-EMoHub" style="text-align:left" dir="ltr">v.clean input=clusters
                type=centroid output=clusters_clean2 tool=rmdupl</span></span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr"><span id="gmail-m_1447804715120165781gmail-:4u.co" class="gmail-m_1447804715120165781gmail-tL8wMe gmail-m_1447804715120165781gmail-EMoHub" style="text-align:left" dir="ltr"><br>
              </span></span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr"></span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr">but nothing seemed to do
              the kind of cleaning I wanted. I ended up using brute
              force and removing the extra centroid manually in the GUI.
              That helped with v.what.rast (all cats in the attr table
              were updated) but part of the original and correct
              geometry was clearly gone. I am sure that's not the right
              combination nor the right way either. <br>
            </span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr"><br>
            </span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr">In the wiki [0], I only
              found this piece of text: "If the <b>input polygons have
                logical errors</b>.... You can investigate overlapping
              areas in the imported vector with '<span class="gmail-m_1447804715120165781gmail-plainlinks"><a rel="nofollow" class="gmail-m_1447804715120165781external gmail-m_1447804715120165781gmail-text" href="https://grass.osgeo.org/grass76/manuals/d.vect.html" target="_blank">d.vect</a></span> yourmap
              type=area layer=2' (only overlapping areas have a category
              in layer 2 after import). Additionally you may show the
              centroids of layer=2 to easier find tiny overlapping areas
              with '<span class="gmail-m_1447804715120165781gmail-plainlinks"><a rel="nofollow" class="gmail-m_1447804715120165781external gmail-m_1447804715120165781gmail-text" href="https://grass.osgeo.org/grass76/manuals/d.vect.html" target="_blank">d.vect</a></span> yourmap
              type=centroid layer=2'" <br>
            </span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr"><br>
            </span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr">However, it says nothing
              about how to proceed further as to keep correctly
              overlapping polygons, each with its own centroid and
              remove the duplicated ones that are generated when
              importing.</span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr"><br>
            </span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr">Can someone please share
              the set of steps that should be followed in these cases?
              Maybe it's a silly question, but I'm more a raster person
              so I am very easily lost with vector issues.</span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr"><br>
            </span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr">Thanks much in advance!</span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr">Vero<br>
            </span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr"><br>
            </span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr"></span></div>
          <div><span id="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-:4u.co" class="gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-tL8wMe gmail-m_1447804715120165781gmail-m_-4881497591274067376gmail-EMoHub" style="text-align:left" dir="ltr">[0] <a href="https://grasswiki.osgeo.org/wiki/Vector_topology_cleaning" target="_blank">https://grasswiki.osgeo.org/wiki/Vector_topology_cleaning</a><br>
            </span></div>
        </div>
      </div>
      <br>
      <fieldset class="gmail-m_1447804715120165781mimeAttachmentHeader"></fieldset>
      <pre class="gmail-m_1447804715120165781moz-quote-pre">_______________________________________________
grass-user mailing list
<a class="gmail-m_1447804715120165781moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a>
<a class="gmail-m_1447804715120165781moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">https://lists.osgeo.org/mailman/listinfo/grass-user</a></pre>
    </blockquote>
    <pre class="gmail-m_1447804715120165781moz-signature" cols="72">-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918</pre>
  </div>

</blockquote></div>