If I have a network of roads. Each road consist of segments. I need to delete all segments that are starting segments of each road and also delete all side roads (dangling) which are represented with only one segment. I do not have idea how to realize this. Any tips? To delete such lines actually means not to proceed them further.
fme-form – How to Find and Fix Dangling Lines in FME Form
fme
Related Solutions
You can analyze polylines in amazing ways by using buffers. This is usually inefficient--buffers create many additional vertices--but (a) it is a technique available in many GISes (vector or raster based) and (b) it sometimes can produce information that is otherwise hard to get.
In this case, buffering the road by a small amount and then buffering by the negative of the same amount leaves little "islands" around all bends and around all intersections. This is easy to prove geometrically.
Here is an example of a 10 m polyline buffer (gray) and its -10 m buffer (light red) in a map that is 650 m wide:
Now intersect the original polyline layer with these island polygons, merge the segments by island identifier, and count the pieces:
The light yellow segments designate the high-count pieces and the dark cyan segments designate the low-count ones. In this fashion we have (a) found all bends and intersections (including self-intersections) and near junctions (see the extreme left, where the two segments do not quite meet)) and (b) differentiated the bends from the intersections. We can find the almost-junctions by selecting the islands that contain two or more connected segments: the bends contain only connected segments.
Due to the symmetry of buffering, the centroids of the intersection islands are the points of intersection.
One beautiful aspect of this style of analysis is that it does not care how the underlying polyline is represented: it could be a single feature, it could be one feature for each line segment, or anything in between.
You can use LineJoiner
transformer with parameter List Name
. But you need to do some additional data processing:
- Use
LengthCalculator
to calculate lengths. - Use
Sorter
to sort your lines by length (numeric sort, descending). - Use
LineJoiner
to join lines. The biggest ones first (thanks to step 2). Specify parameterList Name
of theLineJoiner
- some name for new list attribute. - Use
ListIndexer
with list index 0 - to get the first joined feature (the biggest one) attributes' from the list.
Here is how it will look:
EDIT1:
In order to be able to join only <1m features to bigger ones we need additionally to use:
Tester
transformer after LengthCalculator with test:_length < 1
- Use
SpatialFilter
(tests to perform parameter:TOUCHES
) after Tester to filter only that features which touch features <1m. Then perform line joining on them together with <1m features. Features that don't touch <1m, direct to output (or further processing).
Model:
EDIT2:
If you have <1m line that touches two big ones then they all will be joined together. If such case (<1m feature touches two or more big ones) is possible in your data then you should add some processing of such cases. Take a look at parameters Merge Attributes
and Attribute Prefix
of transformer SpatialFilter
. Using these parameters you should be able to detect such cases and then do some additional filtering.
EDIT3:
Let's solve the case when you have two big lines touching one small (<1m). We need to take only one of the big lines to participate in joining with small one.
In order to be able to perform such filtering we need to mark these two big features with some id from small one they are touching. As stated in EDIT2, it can be done in SpatialFilter
transformer using parameters Merge Attributes
and Attribute Prefix
.
Then use transformer DuplicateRemover
to filter such duplicate features (two big) and take only one of them.
Hint: try to use Inspector
transformer during creating your model and view intermediate results in any case that is not clear to you. In such way you will better understand how each of the transformers are working. Experiment with your data! :)
Best Answer
You can find lines that are only a single segment by using the CoordinateCounter. Throw away anything that has a count of 2. Doesn't always mean they are a dangle though.
The surer - but longer - method would be to use the TopologyBuilder and check to see where a segment has a node ID that is not referenced by any other segment. Then it must be a dangle.