I have about 1000+ running routes which I can load into memory as polylines using latitude and longitude data captured from a running watch. From these polylines I would like to be able to identify routes that match a segment of that polyline as shown on the map (black).

enter image description here

Any advice on a method or mathematical method to be able to give me a confidence score that the marked segment is contained within the bigger segment. I ask for a confidence score, as there will always be GPS drift so I want to match segments that have say 95% confidence that the two lines are the same say buffered to 10 meters.

I am going to implement this using C# when I work out how but just need a point in the right direction.

  • 1
    Specify the GIS application you are using. ArcGIS techniques I could mention may not be applicable to QGIS or other GIS applications. For ArcGIS the Locate Features Along Route tool would be the starting point, although that will not give a confidence rating. The confidence rating is something you would have to design once you had the set of possible matching segments that tool came up with that were within your offset tolerance distance. Network Analyst tools also might work, but I am not experienced in their use. – Richard Fairhurst Feb 20 '15 at 18:41
  • Hi, I was looking for a suggestion for code or mathematic method rather than applications – Ollie Feb 20 '15 at 18:56
  • 1
    Give the application or I won't give the code or math. Code and tools are specific to each application. I am wasting my time providing ArcGIS based solutions if you intend to do this in QGIS. – Richard Fairhurst Feb 20 '15 at 19:36
  • 1
    ArcGIS solutions also require that I know the version you are working with. Many 10.1+ solutions may fail at 10.0 or before. – Richard Fairhurst Feb 20 '15 at 19:44
  • Find distance for every vertex in black line to nearest segment in red. en.wikipedia.org/wiki/Distance_from_a_point_to_a_line. If all of the distances within your buffer... – FelixIP Feb 21 '15 at 9:16

Look into the SpatialLITE library. I would approach the problem by first loading your routes, then use buffer syntax on your 'segment of interest' with the 10 meters as buffer distance.

Next, intersect the resulting buffer with all of your 1000+/- routes; the resulting intersection set will all have geometric lengths. If any lengths of the route intersection candidates approximate the length of your 'segment of interest' then those candidates match.

That is to say, they fall within 10m of your interest segment along the entire length of your interest segment.

You can check these results with some free GIS tools just to get confirmation, but a coded application with file-based inputs/outputs will work for you just as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.