#397: v.clean creates polygons instead of holes
-------------------------+--------------------------------------------------
Reporter: cgsbob | Owner: grass-dev@lists.osgeo.org
Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: Vector | Version: unspecified
Keywords: | Platform: Unspecified
Cpu: Unspecified |
-------------------------+--------------------------------------------------
I'm having problems with this sequence of commands:
r.to.vect -s input=lszone output=lszone10 feature=area
v.clean input=lszone10 output=lszone10_clean tool=rmarea thresh=2800
Below is the output and I've attached a jpeg to illustrate the problem.
Overlaying lszone and lszone10_clean, I see that there are large holes
that have been replaced with polygons. Is this a bug?
Btw, I've tried this with QGIS on Windows XP as well as GRASS 6.4.svn with
the same results.
Bob
======================================================================
r.to.vect -s in=lszone out=lszone10 feature=area
Extracting areas...
100%
100%
Building topology for vector map <lszone10>...
Registering primitives...
50074 primitives registered
629002 vertices registered
Building areas...
100%
27613 areas built
17107 isles built
Attaching islands...
100%
Attaching centroids...
100%
Number of nodes: 39568
Number of primitives: 50074
Number of points: 0
Number of lines: 0
Number of boundaries: 33886
Number of centroids: 16188
Number of areas: 27613
Number of isles: 17107
Number of areas without centroid: 11425
r.to.vect complete.
v.clean in=lszone10 out=lszone10_clean tool=rmarea thresh=2800
--------------------------------------------------
Tool: Threshold
Remove small areas: 2.800000e+03
--------------------------------------------------
Copying vector lines...
Rebuilding parts of topology...
Building topology for vector map <lszone10_clean>...
Registering primitives...
50074 primitives registered
629002 vertices registered
Building areas...
100%
27613 areas built
17107 isles built
Attaching islands...
100%
Attaching centroids...
100%
Number of nodes: 39568
Number of primitives: 50074
Number of points: 0
Number of lines: 0
Number of boundaries: 33886
Number of centroids: 16188
Number of areas: 27613
Number of isles: 17107
Number of areas without centroid: 11425
--------------------------------------------------
Tool: Remove small areas
26251 areas of total size 9.34119e+06 removed
--------------------------------------------------
Rebuilding topology for output vector map...
Building topology for vector map <lszone10_clean>...
Registering primitives...
4913 primitives registered
222687 vertices registered
Building areas...
100%
1362 areas built
1127 isles built
Attaching islands...
100%
Attaching centroids...
100%
Number of nodes: 4678
Number of primitives: 4913
Number of points: 0
Number of lines: 0
Number of boundaries: 4185
Number of centroids: 728
Number of areas: 1362
Number of isles: 1127
Number of duplicate centroids: 3
Number of areas without centroid: 637
I'm trying to attach my raster to this ticket, but it is too large (about
305KB). This file was created using the GRASS-Addon called r.pack
(located at [http://grass.osgeo.org/wiki/GRASS_AddOns#r.pack]. Can I send
this file to someone for testing?
Replying to [comment:2 msieczka]:
> Replying to [comment:1 cgsbob]:
> > I'm trying to attach my raster to this ticket, but it is too large
(about 305KB).
>
> It's an gzipped tar. Try crunching it more with 7zip. Might do.
I tried 7zip on my file and ended up getting a larger file. Even when I
tried to use Ultra compression.
Replying to [comment:6 hamish]:
> fyi, if you have a gmail account you can have 100mb of webspace for
files from pages.google.com. max file size is 10mb I believe.
>
>
> Hamish
I do have a gmail. Thank you for the tip...I'll use it next time I have a
large file to share.
I was wondering if anyone has had a chance to look at my raster? It would
be nice to at least get confirmation that others have the same problem or
I am just doing something wrong.
The problem is the detail of the vector map and the threshold for v.clean
tool=rmarea. With a threshold of 2800 you reduce the vector from input
Number of areas: 27613, Number of isles: 17107 to output Number of areas:
1362, Number of isles: 1127. This is far too much, too many boundaries and
centroids are deleted or rewritten to the coor file, topology can not be
properly maintained on the fly: sometimes an existing centroid for an area
can not be found. Although the boundaries have been deleted, the centroid
is still there and assigned to the (new) area it lies in when topo is
fully built again (the output also has duplicate centroids, for the same
reason). What was an area without centroid is now an area with centroid,
GRASS speak meaning something similar like ESRI speak "polygon instead of
hole". What may in theory work is to rewrite Vect_remove_small_areas() so
that topo is completely and properly rebuild every time an area is
removed, but that is not an option, cleaning would take ages. v.clean
tool=rmarea seems to work fine as long as not more than roughly 25% of the
areas and isles are removed.
Since you are not interested in this high level of spatial detail present
in the vector lszone10, you can also
1. in the raster lszone replace NULL with 0
2. run a neighborhood filter window size 5 operation median
3. replace 0 with NULL in the filtered raster
4. r.to.vect, gives me 3136 areas and 3001 isles
optionally 5. v.clean tool=rmarea thresh=2800 if there is still too much
detail
Works like a charm, everything done in a few minutes.
Replying to [comment:10 mmetz]:
> fixed in trunk r36192 and devbr6 r36193
>
> TODO: fix in 6.4 after more testing
I finally had a chance to update devbr6 and ran v.clean on my problem
vector file. It works very well. It would be great if this can be back
ported to 6.4.
Replying to [comment:11 cgsbob]:
> Replying to [comment:10 mmetz]:
> > fixed in trunk r36192 and devbr6 r36193
> >
> > TODO: fix in 6.4 after more testing
> I finally had a chance to update devbr6 and ran v.clean on my problem
vector file. It works very well. It would be great if this can be back
ported to 6.4.
>
The fix seems to work, so I backported it to 6.4 in r36728. Closing
ticket.