[GRASS-user] importing and cleaning overlapping polygons that are supposed to overlap
mlennert at club.worldonline.be
Thu May 16 02:20:05 PDT 2019
On 16/05/19 03:11, Veronica Andreo wrote:
> Dear all,
> thanks for the answers...
> @Madi, I know, but that's how I got the data from a colleague using
> SaTScan to get cluster sizes.
> 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.
> 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.
To see the cat values of layer 3 you have to indicate that layer in the
label_layer parameter (Labels tab).
You can also see the correspondance between the two layers with
v.category polys_3layers op=print layer=1,3
> 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?
This depends on how you want to get raster values. If v.what.rast at the
location of the centroid is all you need than Micha's solution should work.
If you need v.rast.stats then you either have to use Markus' suggestion,
or you use Micha's approach running v.rast.stats on layer three and then
use some magic to transform the output of the above v.category call to a
correspondance table between layer. Something like this
import grass.script as g
for feature in g.read_command('v.category',
cat1 = feature.split('|')
cats2 = feature.split('|').split('/')
for cat2 in cats2:
print cat1, cat2
This correspondance table could then be used to aggregate the raster
stats per (original) polygon in SQL. This could be the easily put into
an addon module.
More information about the grass-user