Opened 16 years ago

Closed 16 years ago

#397 closed defect (fixed)

v.clean creates polygons instead of holes

Reported by: cgsbob Owned by: grass-dev@…
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)

v_clean_prob.jpg (223.0 KB ) - added by cgsbob 16 years ago.
vector file before and after v.clean
rad_zn2.7z (238.6 KB ) - added by msieczka 16 years ago.
Bob's sample raster map - r.pack > gunzip > untar > 7z

Download all attachments as: .zip

Change History (14)

by cgsbob, 16 years ago

Attachment: v_clean_prob.jpg added

vector file before and after v.clean

comment:1 by cgsbob, 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?

in reply to:  1 ; comment:2 by msieczka, 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.

in reply to:  2 ; comment:3 by cgsbob, 16 years ago

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.

in reply to:  3 comment:4 by msieczka, 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 msieczka, 16 years ago

Attachment: rad_zn2.7z added

Bob's sample raster map - r.pack > gunzip > untar > 7z

comment:5 by msieczka, 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.

comment:6 by hamish, 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

in reply to:  6 comment:7 by cgsbob, 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 cgsbob, 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 mmetz, 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

  1. in the raster lszone replace NULL with 0
  1. run a neighborhood filter window size 5 operation median
  1. replace 0 with NULL in the filtered raster
  1. 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

comment:10 by mmetz, 16 years ago

fixed in trunk r36192 and devbr6 r36193

TODO: fix in 6.4 after more testing

in reply to:  10 ; comment:11 by cgsbob, 16 years ago

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.

Thank you for fixing this bug.

Bob

in reply to:  11 comment:12 by mmetz, 16 years ago

Resolution: fixed
Status: newclosed

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.

Note: See TracTickets for help on using tickets.