[GRASS-user] remove holes from polygon

Robert Nuske rsn.mailinglists at gmail.com
Fri Oct 9 07:05:19 PDT 2020


Hi Moritz


>> Is there a way to automatically (not by manually editing the dataset)
>> remove all holes in all areas of a vector dataset (I guess that are
>> polygons without a category within polygons with a category).
> 
> What do you mean by remove ? Fill them as separate polygons ? Make them 
> part of the containing polygon ?

The holes shall become parts of the bigger containing polygon.

I dreamed there could be a way to drop "rings" which do not have 
categories. Or something like PostGIS' ST_ExteriorRing.


> If the latter and if the holes are all smaller than existing polygons, 
> one possible path I see is making them into actual areas using 
> v.centroids and then merge them with the outside polygon using v.clean 
> with the tool=rmarea.

Interesting, that could work.

I ended up using a slight variation, using dissolve instead of clean to 
not having to come up with a minimum area:


v.centroids in=poly_with_holes out=poly_centroids

v.category in=poly_centroids option=del cat=-1 out=poly_no_cat
v.category input=poly_no_cat output=poly_same_cat option=add step=0

v.dissolve in=poly_same_cat out=poly_no_holes


Thank you very much Moritz!
   Robert


More information about the grass-user mailing list