Question

Find a line within a line?

  • 22 December 2016
  • 7 replies
  • 24 views

Badge

I've been trying to find lines that are on top of another line feature of the same class, but different lengths. I can currently identify any features of the same feature class that are duplicates of one another based upon geometry and/or attributes with the matcher and duplicate filter, but can't seem to figure out how to identify the shorter line segments that are within a line. Sometimes they have shared vertices and sometimes they will not.


7 replies

Userlevel 2
Badge +17

Hi @madwarren, the SpatialRelator might help you. Send all the line features to both the Requestor and the Supplier port, and set:

  • Tests to Perform: Within
  • Attributes that Must Differ: OID

You can then check the number of related suppliers for each output line to determine if the line was within another line.

Note that there could be a case where the SpatialRelator cannot detect the spatial relationship if the shorter line has vertices that are not shared by the longer line, because of unavoidable computational error. In such a case, consider transforming the Supplier lines to slenderlong polygons using the Bufferer with a slight buffer amount.

Badge +16

Optionally use the SpatialFIlter, or as suggested buffering.

Userlevel 1
Badge +21

If there are not always shared vertices I've never found spatial relators/spatial filters alone to be very reliable for lines. I've always ended up having to buffer or similar (but that can sometimes bring its own issues). Spatial comparisons with a tolerance is high on my wishlist for this reason

Badge

Hi @madwarren, the SpatialRelator might help you. Send all the line features to both the Requestor and the Supplier port, and set:

  • Tests to Perform: Within
  • Attributes that Must Differ: OID

You can then check the number of related suppliers for each output line to determine if the line was within another line.

Note that there could be a case where the SpatialRelator cannot detect the spatial relationship if the shorter line has vertices that are not shared by the longer line, because of unavoidable computational error. In such a case, consider transforming the Supplier lines to slenderlong polygons using the Bufferer with a slight buffer amount.

@takashi That seems to be my issue. When the shorter line segment doesn't share any vertices it will not find the line to be "within" and therefore reports 0 _related_candidates. I will try to use your recommended buffering technique. Thanks for the help.

 

 

 

Badge

If there are not always shared vertices I've never found spatial relators/spatial filters alone to be very reliable for lines. I've always ended up having to buffer or similar (but that can sometimes bring its own issues). Spatial comparisons with a tolerance is high on my wishlist for this reason

That is my issue because the shorter line segments don't always share the same vertices. I will try the suggested buffering. Thanks for your help.

 

 

Userlevel 2
Badge +16

You can try this:

Use the LineonLineOverlayer and a Tester to test all line segments with _overlap = 2

Then route these as Candidate in the SpatialFilter (filter EQUALS) to compare to the originals lines.

All line segments that have _overlaps=2 and are EQUAL to an original completely fall within another line.

Badge

Thanks everybody for their suggestions and help with this matter. I went with a buffering technique. I ended up using a matcher to filter out geometry matches and if found send a single feature through. I then did a small buffer on those lines and send them into the spatial relator as the requestor. I set it up to "requestor contains supplier", attributes differ "OBJECT ID", and created a list with the Object ID's. Tested the output on _related_candidates >= 1.

Then I can identify the segments that are within a line from the list attached to the features.

Reply