5

I have driven along some roads and registered some information about the state of the edge of the road. The GPS coordinates are not very precise, and I would like to smooth or snap the tracked lines to the actually edges of the road. All data is registered driving at the right direction in the right side of the road. I have three layers with data.

  1. Red layer is the edges of the road.
  2. Blue layer is the center lines of the road.
  3. Green layers is the tracks registered by the GPS with some attributes about the state of the side of the road. Look at the image at the bottom.

I have many of these and would like to automatically smooth or snap the points of the green lines to the right side of the road, to make them follow the red line.

How can I do that using MapInfo?

Just some mathematical description how to solve it would be nice. I am not asking for a full MapBasic script that solves it.

My initial thought is to find the nearest red line to a chosen green line. For each vertex in the green line get a vector to the nearest point on a red line segment and move the vertex by this vector. But I can see the GPS is sometimes very unstable and the green line is on the wrong side of the center line. In some way I need to find the nearest red line to the "right" of the blue center line and move the vertices to this.

I put some white arrows on the image to illustrate where to move the green lines to.

Perhaps a totally different way can be used?

Map with vector data

4
  • 1
    Please decide whether you wish to ask about QGIS or MapInfo in this particular question. If you seek code or help with code then you need to include some.
    – PolyGeo
    Commented Aug 18, 2017 at 12:52
  • How come I am not allowed to ask about two products at once? I prefer MapInfo as this is the main tool I work with, but I know that there are lot's of skilled QGIS people out there. I need to ask the same question twice then if I also want a QGIS solution to the problem?
    – nivs1978
    Commented Aug 21, 2017 at 6:04
  • Anyway I edited now to only ask about MapInfo.
    – nivs1978
    Commented Aug 21, 2017 at 6:08
  • @nvis1978, The questions on this site should be focused and limited to a single software. Multiple software tags are viewed as too broad. Please visit our help center page and our tour. I've reopened your question now.
    – Fezter
    Commented Aug 21, 2017 at 6:11

1 Answer 1

2

Here are some ideas:

  1. Convert your green polygons into points where each node will be a point in a new table referring back to the original record and the node number.

  2. Use the Distance Calculator to calculate the two shortest distances between the "green" points and the red lines

  3. Use a query to find all the distance lines that intersect a green line with an ID different than the original ID. They seem to cross another green line to get to a red line. You don't want to use these. Delete those that were found.

  4. For each of the green lines, select the distance lines sort them by node and distance.

  5. For each of the sorted distance lines, get the Node ID, if you already have looked at this node ID ignore it, move the matching node of the current green line to the end point of the distance line and finally save back the edited green line to the current record in the green line table.

You might want to build in some extra validations too. Maybe check that the distance you are moving is less than a certain distance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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