[GRASS5] Re: [5.7] remove islands and U-dangles?

Radim Blazek blazek at itc.it
Wed May 12 03:50:20 EDT 2004


On Wednesday 12 May 2004 01:42, Hamish wrote:
> > > The following patch makes the -d (dissolve) function of v.extract
> > > work.(this is against today's CVS)
> > >
> > > It works, but probably needs some cleanup before putting in CVS..
>
> I'll try and do this today..

But the problem is not to dissolve boundaries, the problem is to choose 
only one centroid. OK, put it to CVS and I'll look at the centroids,
I think that I'll generate new centroids for merged areas, and query 
the area in the input map. It would be also possible (faster) to simply
remove all duplicate centroids (negative LINE->left).

> > > Also, 'v.extract type=area list=1,2,3' keeps areas with missing
> > > centroids; how do you automatically add missing centroids so you can
> > > then get rid of the zombie areas with another [xxxxxxxx]?
>
> => 'v.extract -d list=1-50000'
>
> I thought 'v.clean tool=bpol' would do this, but it doesn't.
> Should it? Or should/is this better in another tool?

So again, any space closed by boundary, even if it does not have any centroid
is area. It is area without centroid, without category. 
We can discuss, if d.vect should (and when) display those areas, se more below.
It is not a bug! It is not a bug! It is not a bug!

v.clean tool=bpol breaks closed polygons, like those imported from Shapefile,
the result is similar as tool=break, but polygons are broken only on 
common vertices. 'bpol' is much faster than 'break', but usually
(because simple feature data are not clean) 'break' must be used as well.

> If the number of left-over broken areas is small, then for now you can
> remove them with v.digit.. :/

No! The areas are enclosed by other areas which cannot be removed!

> > I have tested the module patch with part of the spearfish location and
> > made some screeshots. Maybe I can help to make it clearer.
> >
> > 1) http://www.gdf-hannover.de/dassau/muell/d.vect.png
> >
> > Visualize spearfish soils data:
> > d.vect soils where='cat<20'
> >
> > 2) http://www.gdf-hannover.de/dassau/muell/v.extract.png
> >
> > Using v.extract without dissolve option
> > v.extract in=soils out=soils2 type=area,centroid where='cat<20'
> >
> > -> extracted areas within areas don't have an centroid anymore but are
> > still visualized, although they should be deleted, as with d.vect.
> > Topologically, this might be correct, because an area is surrounded by
> > boundaries, but it should not be displayed, I think.
>
> See above. I don't know the solution to this.
> Is this a display bug or a topology bug?
>
> ** note ps.map->vector fill has this problem too **

It is not a bug! Neither in display nor in topology.
We can change how d.vect works if you are sure that it 
should be changed. I am not sure, it will solve your present 
problem but creates another.
Say that d.vect displays only areas with category of given field
(that is what you want, I think?) then people will complain
that they cannot see areas without centroids, e.g. imported 
from CAD. Here we must decide if it is better to see sometimes
more than user wants, or less than he expects. I am sure that
it is better to see more, you can think about waht you see and why. 
To import data and see nothing is depressing.
You can use d.vect map=soils2 cats=1-10000 to see only areas with category.

In QGIS, one field means layer. If an area in GRASS has a category of 
field 1, it is represented as feature in the layer polygon_1.
But it is different from GRASS, because user can see in the dialog,
that there is also layer polygon_0 (islands without category)
and he can add it to the map as another layer. 


http://mpa.itc.it/radim/isle3.png
http://mpa.itc.it/radim/isle2.png
http://mpa.itc.it/radim/isle1.png

I don't know if it is good or not, we have to test it,
but it seems that it is more suitable in most cases and for
most users. 

My suggestion is to leave d.vect and d.what.vect as it is 
with all the complexity for experts and follow layer approach
(as described above) in user-friendly viewers.
I would appreciate, if you could try QGIS and tell me if it
does what you expect. If we find the QGIS approach good, the 
same will be used for GRASS driver in OGR.

> > 3) http://www.gdf-hannover.de/dassau/muell/v.extract_d.png
> >
> > Using v.extract with dissolve option
> > v.extract -d in=soils out=soils3 type=area,centroid where='cat<20'
> >
> > -> areas with cat<20 are dissolved (very nice), but now areas with
> > dublicated centroids exist. And areas cat='21 and 43' still exist but
> > without centroid, as in example 2.
>
> v.clean tool=rmdac   # remove duplicate area centroids

This is right.

> I'm not sure how it decides which one to keep, but I'd suspect the
> area's cat might not be correct after this step.

The first found centroid is keept and all others are duplicate (removed).
The category will be correct, because boundaries are dissolved only
between areas with the same category.

> Probably extract.c's dissolve needs to work on centroids somehow (right
> now it's only boundaries).

Yes, as I said above. Let me know once you commit dissolve boundary patch
and I'll look at centroids. Or you can do it yourself,
Vect_build()
for each centroid 
  if area < 0 // duplicate
     Vect_delete_line

see also grass51/vector/v.clean/rmdac.c

The same must be done in v.reclass

Radim




More information about the grass-dev mailing list