Difference between revisions of "Vector remove small lines"

From GRASS-Wiki
Jump to: navigation, search
m
(expanded)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
'''Q:''' How to remove small vector lines? I want to only delete spurious lines.
+
'''Q:''' How to remove small vector lines? I want only delete spurious lines.
  
'''A1:''' You may the following approach:
+
'''A:''' You may choose from the following approach (please read all of them before starting):
 +
 
 +
'''Approach 1:'''
 +
 
 +
To delete isolated lines which are not connected to the main "network", use:
 +
  {{cmd|v.net.alloc}} in={your input vector} out={output vector} ... (TBD)
 +
 
 +
'''Approach 2:'''
 +
 
 +
To globally delete short vector segments, considering them as dangles, use:
 +
  {{cmd|v.clean}} in={your input vector} tool=rmdangle thresh={your threshold} out={output vector}
 +
 
 +
'''Approach 3:'''
  
 
* use {{cmd|v.build.polylines}} to join broken vector segments into longer segments
 
* use {{cmd|v.build.polylines}} to join broken vector segments into longer segments
Line 10: Line 22:
 
   {{cmd|v.extract}} in=mypolyline out=mypolyline_over5km type=line where="length_km > 5.0"
 
   {{cmd|v.extract}} in=mypolyline out=mypolyline_over5km type=line where="length_km > 5.0"
  
'''A2:''' Alternative approach:
+
'''Approach 4:'''
  
Removes from vector map all lines with length shorter than 50 map units (thresh: threshold distance (coords,snap,query)):
+
To remove all lines with a length shorter than 50 map units (thresh: threshold distance (coords,snap,query)) globally:
 
  {{cmd|v.edit}} mymap tool=delete query=length thresh=-1,0,-50 type=line
 
  {{cmd|v.edit}} mymap tool=delete query=length thresh=-1,0,-50 type=line
 +
 +
You can also define a bounding box in v.edit to limit the operation to a subset of the map.
  
 
== See also ==
 
== See also ==

Latest revision as of 03:52, 5 November 2014

Q: How to remove small vector lines? I want only delete spurious lines.

A: You may choose from the following approach (please read all of them before starting):

Approach 1:

To delete isolated lines which are not connected to the main "network", use:

  v.net.alloc in={your input vector} out={output vector} ... (TBD)

Approach 2:

To globally delete short vector segments, considering them as dangles, use:

  v.clean in={your input vector} tool=rmdangle thresh={your threshold} out={output vector}

Approach 3:

  • use v.build.polylines to join broken vector segments into longer segments
  • then use v.to.db with option=length (line length) to upload the vector segment lengths to the attribute table
  v.db.addcol mypolyline column="length_km double precision"
  v.to.db mypolyline type=line option=length units=k column=length_km
  • now use v.extract to extract the longer vector segments into a new map according to a threshold you need. Example: Extract line features longer than 5km (cleans out the noise):
  v.extract in=mypolyline out=mypolyline_over5km type=line where="length_km > 5.0"

Approach 4:

To remove all lines with a length shorter than 50 map units (thresh: threshold distance (coords,snap,query)) globally:

v.edit mymap tool=delete query=length thresh=-1,0,-50 type=line

You can also define a bounding box in v.edit to limit the operation to a subset of the map.

See also