Rechercher une page de manuel

Chercher une autre page de manuel:


Langue: en

Version: 329925 (ubuntu - 24/10/10)

Section: 1 (Commandes utilisateur)


v.clean - Toolset for cleaning topology of vector map.


vector, topology


v.clean help
v.clean [-b] input=name output=name [type=string[,string,...]] [error=name] tool=string[,string,...] [thresh=float[,float,...]] [--overwrite] [--verbose] [--quiet]



Don't build topology for the output vector

Allow output files to overwrite existing files

Verbose module output

Quiet module output



Name of input vector map

Name for output vector map

Feature type
Options: point,line,boundary,centroid,area,face,kernel
Default: point,line,boundary,centroid,area

Name of output map where errors are written

Cleaning tool
Options: break,snap,rmdangle,chdangle,rmbridge,chbridge,rmdupl,rmdac,bpol,prune,rmarea,rmline,rmsa
break: break lines at each intersection
snap: snap lines to vertex in threshold
rmdangle: remove dangles, threshold ignored if < 0
chdangle: change the type of boundary dangle to line, threshold ignored if < 0, input line type is ignored
rmbridge: remove bridges connecting area and island or 2 islands
chbridge: change the type of bridges connecting area and island or 2 islands from boundary to line
rmdupl: remove duplicate geometry features (pay attention to categories!)
rmdac: remove duplicate area centroids ('type' option ignored)
bpol: break (topologically clean) polygons (imported from non topological format, like ShapeFile). Boundaries are broken on each point shared between 2 and more polygons where angles of segments are different
prune: remove vertices in threshold from lines and boundaries, boundary is pruned only if topology is not damaged (new intersection, changed attachement of centroid), first and last segment of the boundary is never changed
rmarea: remove small areas, the longest boundary with adjacent area is removed
rmline: remove all lines or boundaries of zero length, threshold is ignored
rmsa: remove small angles between lines at nodes

Threshold in map units, one value for each tool (default: 0.0[,0.0,...])


v.clean allows the user to automatically fix topology of vector maps.

Break lines/boundaries


Threshold does not apply, use dummy value if v.clean is run with several tools.

The break tool breaks lines/boundaries at intersections and also breaks lines/boundaries forming a collapsed loop, for example 0.0;1.0;0.0 is broken at 1.0.

Breaking lines should be followed by removing duplicates, e.g. v.clean tool=break,rmdupl.

Remove duplicate geometry features


Threshold does not apply, use dummy value if v.clean is run with several tools.

The rmdupl tool removes geometry features with identical coordinates. Categories are merged. If a point and a centroid have identical coordinates, one of them will be removed if both points and centroids are selected with v.clean type=point,centroid. The same applies for lines and boundaries.

The rmdupl tool should be used after breaking lines and breaking polygons.

Remove dangles or change boundary dangles to type line

tool=rmdangle and tool=chdangle

Threshold gives maximum line/boundary length in map units, degrees for latlon. Dangles shorter than thresh are removed sequentially. All dangles will be removed if thresh < 0.

A line/boundary is considered to be a dangle if no other line of given type is on at least one end node. If a dangle is formed by several lines, such a string of lines is taken as one dangle and line lengths are summarized. The rmdangle tool deletes a dangle if the (combined) length is shorter than thres or thres < 0. If the combined length is larger than thresh, nothing is deleted.

With thresh < 0, only closed loops and lines connecting loops will remain. This is useful to remove all incorrect boundaries after other cleaning operations with thres is < 0. Areas can then be successfully built.

To preferentially remove shortest dangles first, a first pass with a small thresh value can be followed by subsequent passes with increasing thresh values.

The chdangle tool is similar to the rmdangle tool, but works only on boundaries and changes dangling boundaries to lines instead of removing dangles.

Remove or change bridges connecting an area and an island or two islands

tool=rmbridge and tool=chbridge

Threshold does not apply, use dummy value if v.clean is run with several tools.

A bridge is an area type connection of an island (polygon in a polygon) to the outer polygon. This is topologically incorrect (but OGC Simple Features allow it). The rmbridge tool removes bridges and the chbridge tool changes bridges to type line:

    +-------------+             +-------------+   +-------------+

    |            P|  P: polygon |            P|   |            P|

    |    +---+    |  I: island  |    +---+    |   |    +---+    |

    |    | I |    |  B: bridge  |    | I |    |   |    | I |    |

    |    |   |    |  L: line    |    |   |    |   |    |   |    |

    |    +-+-+    |             |    +---+    |   |    +-.-+    |

    |      |      |             |             |   |      .      |

    |      | B    |             |             |   |      . L    |

    |      |      |             |             |   |      .      |

    +------+------+             +-------------+   +-------------+

Islands and areas must be already clean, i.e. without dangles or small angles, e.g. v.clean type=boundary tool=rmdangle,rmsa,break,rmdupl,rmbridge thresh=-1,0,0,0,0.

Snap lines to vertex in threshold


Threshold gives maximum distance to another vertex in map units, degrees for latlon.

The snap tool snaps vertices to another vertex not farther away than thresh. If there is no other vertex within thresh, no snapping will be done. The type option can have a strong influence on the result. A too large threshold and type=boundary can severely damage area topology.

Snapped boundaries may need to be cleaned with rmdangle,break,rmdupl.

Remove duplicate area centroids


Threshold does not apply, use dummy value if v.clean is run with several tools.

The rmdac tool removes duplicate area centroids that can result from deleting boundaries.

Break (topologically clean) areas (imported from a non topological

format like ShapeFile) tool=bpol

Threshold does not apply, use dummy value if v.clean is run with several tools.

The bpol tool breaks boundaries on each point shared between 2 and more areas where angles of boundary segments are different and on all boundary nodes (start and end points of each boundary). The bpol tool behaves similar to break for boundaries, but does not break collapsed loops. The bpol tool is faster than the break tool but needs more memory.

The bpol tool should be followed by rmdupl.

Remove vertices in threshold from lines and boundaries


The prune tool simplifies lines and boundaries by removing vertices according to threshold. This tool preserves area topology, areas are never deleted and centroid attachment is never changed. v.generalize offers much more functionality for line simplification but does not preserve area topology.

Remove small areas


Threshold gives area size in map units, square meters for latlon.

The rmarea tool removes all areas <= thresh. The longest boundary with an adjacent area is removed or all boundaries if there is no adjacent area. Area categories are not combined when a small area is merged with a larger area.

Remove all lines or boundaries of zero length


Threshold does not apply, use dummy value if v.clean is run with several tools.

The rmline tool removes all lines or boundaries of zero length that may have resulted from other cleaning operations. Zero length boundaries are redundant and do not influence area topology.

Remove small angles between lines at nodes


Threshold does not apply, use dummy value if v.clean is run with several tools.

The rmsa tool only concerns angles which are so small that the calculated angle is 0. The following figure should help demonstrate what the tool does.



The rmsa tool should be followed by break,rmdupl.


The user does not have to run on the output vector, unless the -b flag was used. The -b flag affects only the output vector - topology is always built for error vector.


Snap lines to vertex in threshold

v.clean input=testmap output=cleanmap tool=snap thresh=1

Cleaning OGR imported data (Simple Feature data)

The import of areas with -c (no cleaning) requires a subsequent run of v.clean to update the map to a topologically valid structure (removal of duplicate collinear lines etc). The tools used for that are bpol and rmdupl:
v.clean input=areamap output=areamap_clean tool=bpol,rmdupl type=boundary

Extracting intersection points of vector lines

v.clean input=lines1 output=lines2 err=points tool=break type=line
Intersection points are written to 'points' map.

Break lines

v.clean will break the lines where they cross, creating new node if needed. Example: -n out=crossed_lines format=standard << EOF
L 2

 0 5

 10 5
L 2

 5 0

 5 10

v.clean in=crossed_lines out=crossed_lines_brk \

        error=intersection tool=break type=line

Remove all lines of zero length

v.out.ascii zero format=standard
L 2 1

 -819832.09065589 -987825.2187231

 -806227.28362601 -971104.80702988

 1     1         
L 2 1

 -799165.24638913 -972974.16982788

 -799165.24638913 -972974.16982788

 1     2         

v.clean input=zero output=zero_clean tool=rmline type=line

v.out.ascii zero_clean format=standard
L 2 1

 -819832.09065589 -987825.2187231

 -806227.28362601 -971104.80702988

 1     1         
v.clean type=boundary would remove nothing.

Repeatedly remove dangling lines up to 50m length

v.clean input=testmap output=cleanmap type=line tool=rmdangle,rmdangle,rmdangle,rmdangle thresh=5,10,20,50

SEE ALSO,, v.digit, v.edit


David Gerdes, U.S. Army Construction Engineering Research Laboratory
Radim Blazek, ITC-irst, Trento, Italy
Martin Landa, FBK-irst (formerly ITC-irst), Trento, Italy

Last changed: $Date: 2009-12-14 21:51:52 +0100 (lun, 14 dic 2009) $

Full index

© 2003-2010 GRASS Development Team

L'argent ne fait pas le bonheur... de celui qui m'en a prêté !
-+- Pierre Perret -+-