Opened 16 years ago
Closed 15 years ago
#397 closed defect (fixed)
v.clean creates polygons instead of holes
Reported by: | cgsbob | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 6.4.0 |
Component: | Vector | Version: | unspecified |
Keywords: | Cc: | ||
CPU: | Unspecified | Platform: | Unspecified |
Description
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
Attachments (2)
Change History (14)
by , 16 years ago
Attachment: | v_clean_prob.jpg added |
---|
follow-up: 2 comment:1 by , 16 years ago
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?
follow-up: 3 comment:2 by , 16 years ago
Replying to 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.
follow-up: 4 comment:3 by , 16 years ago
comment:4 by , 16 years ago
Replying to cgsbob:
Replying to msieczka:
Replying to 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.
Pass it over to me by email and I'll upload it to my webpage and link it here, if you can't do it yourself.
by , 16 years ago
Attachment: | rad_zn2.7z added |
---|
Bob's sample raster map - r.pack > gunzip > untar > 7z
comment:5 by , 16 years ago
Bob sent me me his rad_zn2.pack. I gunzipped it, untared and 7zipped instead. Now it's small enough. Hopefully someone can investigate it.
follow-up: 7 comment:6 by , 16 years ago
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
comment:7 by , 16 years ago
Replying to 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.
comment:8 by , 16 years ago
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.
comment:9 by , 16 years ago
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
- in the raster lszone replace NULL with 0
- run a neighborhood filter window size 5 operation median
- replace 0 with NULL in the filtered raster
- 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.
Regards,
Markus M
follow-up: 11 comment:10 by , 15 years ago
follow-up: 12 comment:11 by , 15 years ago
comment:12 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Replying to cgsbob:
Replying to 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.
vector file before and after v.clean