Skip to main content
Question

How to remove gaps in lines created from lists of coordinates

  • February 16, 2017
  • 7 replies
  • 109 views

Forum|alt.badge.img

Hello, this problem probably has a very simple solution but I'm struggling to come up with anything!

My input is a large number of CSV files where each CSV contains a list of coordinates that form a route.

Within each route, there are different travel modes which each need to be represented by a separate line. The travel mode for a segment within a route is identified by an attribute in the input CSV.

To create the lines, I am using a PointConnector transformer, using both the 'route ID' and 'travel mode' attributes as the Connection Break Attributes.

If we joined the the list of coordinates for a route all together, they would form a continuous line, but because we are breaking the routes up by travel mode, the output segments have gaps between them where their ends should meet.

actual result:

desired result:

The gaps are occurring because the start coordinates of one travel mode segment, are also the end coordinates of the previous segment:

If anyone has ideas about how to fix this it'd be much appreciated. Have tried the snapper without much success. There are almost 2000 input files so it's not practical to manually duplicate rows in the data.

7 replies

Forum|alt.badge.img+7

Hi @katiem

I suggest to take a look at the Neighborfinder. It allows you to find a 'neighbor' withing a certain search radius. It also returns the coordinates of the point it snapped to allowing you to create the link.

https://docs.safe.com/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Transformers/neighborfinder.htm


redgeographics
Celebrity
Forum|alt.badge.img+49

The NeighborFinder that @jeroenstiers suggests will leave the original geometries intact. Depending on the size of the gaps it might be better to use the Snapper instead (although this will, subtly, alter the geometry)


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • February 16, 2017

I would use the AnchoredSnapper as I assume the bus stop to be accurate. Snap the walk to the bus stop by using the bus stops as Anchor and the walks as Candidate.


itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • February 16, 2017

Hi @katiem,

You can do that via the AnchoredSnapper and joining the lines to form a longer one.

Hope this helps.


Forum|alt.badge.img
  • Author
  • February 16, 2017

Thanks for the replies all, I've tried the AnchoredSnapper and that seems to work reasonably well for most of the data.

However, I've discovered that there are some features where the middle section only has one row for the segment, so no line is created for that segment (because it only has one set of coordinates, when in reality the start coordinates of the segment are the last set of coordinates from the previous 'walk' segment). I think ideally I need to find a way to append the last set of coordinates from the previous segment as the first set of coordinates on the next segment....


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • February 16, 2017

If you are looking to use the X and Y coordinates of the previous line this can help:

The AttributeCreator transformer has the advanced option to take attributes from the previous feature.

You can use those to create line segments.


Forum|alt.badge.img
  • Author
  • February 17, 2017

Unfortunately I don't think that would work - we only want to do it with specific rows, not all. E.g. for the bus segment, we need to add an additional row, which contains the coordinates of the first row of the walking segment. I now have nearly 4000 files to process so I think the snapping method gives the easiest solution for now.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings