4

I'm looking for a tool that'll help create a GPX file which will help me run a track and create "GPS Art" or "GPS Drawing".

I would like to draw simple shapes, like animals or texts by following a GPX path on my runs. I need a tool that'll take a lines, and given a specific area, will match these lines to a real world road, sidewalk or path network. The tool needs to best match the drawing to the road network as possible to maintain the idea of the shape.

Does such a tool already exists? If not, is there an existing API or algorithm that would help me create the tool?

I'd prefer to write this in Python. I'm not asking for code, but help finding the right existing tool, or algorithm.

  • There are a few websites that already do this. The most popular one is probably Strava. If you want to roll your own, you basically just need to convert the GPX into a format that a given webmap would support. Now-a-days most mapping sites support GPX as an input file type. – KHibma Feb 7 '19 at 13:31
  • 1
    Strava isn't a solution for me. How can I relate, for example, the draw of a snail, like just a black line in a .png and create a track from it in a specific localisation with Strava ? The input of the tool I'm searching for is a simple line drawing, a distance, and an area. – iFlo Feb 7 '19 at 13:34
  • Oh, I misunderstood. You want to draw the features yourself, say on a map, then export that into a GPX file, and put that GPX file on your phone or watch, and you'd follow that path? – KHibma Feb 7 '19 at 13:35
  • I already did that but it's quite time consuming. I would like to draw a shape, like with a pencil on a paper and then it will relate automatically to the nearest roads and paths given a distance and a localisation. – iFlo Feb 7 '19 at 13:37
  • 1
    I updated your question for clarity. I'd also read through this, it may provide some ideas: gis.stackexchange.com/questions/5761/… – KHibma Feb 7 '19 at 13:51
2
+25

That's a REALLY tough assignment. I don't believe there's a vector library that will look for matching patterns like that. If you do try and write your own code, I'd suggest breaking your source down into individual components (eg take the snail's shell and look for that, then take the body and look for it where there was a shell match) - basically simpler is easier.

However, your best bet might be using a pattern matching/machine learning library like OpenCV, which works in raster instead of vector. You'd probably have to train it with some fake road maps that you create with the pattern in it - like you tell it, this is a road network that has a snail in it, and is what I'm looking for. Then feed it all your real road maps and tell it to look for the same pattern. It has a Python interface so it would be OK for you.

2

Bold black lines on the picture shows minimum spanning tree of the graph:

enter image description here

I followed these steps to create graph:

  • nodes: densified original line and projected vertices on the roads; plus road intersections within 70 m from original line;
  • edges: triangulation lines between nodes.

Shortest distance between start and end node of the line along MST will give something very close to your goal. Results can be improved be increasing cost of crossing edges with their center away from road lines.

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.