I'm very new to the PostGIS and QGIS. I'm a student and I am doing thesis work on map matching.

I have segment shapefile of two network one OSM network and other one TMC network. And I have point shapefile of two networks.

Methodology to be done;

  1. I need to find the closest point of OSM points to the TMC point. I have find using closet point buy using distance matrix. The distance matrix attribute table contains inputid as TMC points id and target id as OSM points id and also I also have distance between them.

  2. In OSM network I don't have start and end point of the segments. How can I get start and end points of the segments?

  3. And the my goal is to map TMC SINGLE LINK to OSM PATH.

For each single link between TMC POINTS, I have to find (MAPPING) which is the correspondent path (SEQUENCE OF LINKS) on OSM NETWORK, between the correspondent points OF TMC NETWORK on the OSM NETWORK. On OSM links should be attached the attribute of the link ID OF TMC ELEMENT.

For example, suppose to have the following situation:

TMC NETWORK: POINT 1: ID =500; POINT 2: ID=501; LINK between POINT 1 and POINT 2: ID = 7500

We found that on OSM NETWORK, the correspondent POINT of POINT 1 with ID =500 on TMC, is the OSM POINT 1 with ID = 12349876 We found that on OSM NETWORK, the correspondent POINT of POINT 2 with ID =501 on TMC, is the OSM POINT 2 with ID = 55532481

Now, we have to calculate, on OSM NETWORK, which is the shortest path between the POINT 1 (ID = 12349876 ) and the POINT 2 (ID = 55532481 ) on OSM NETWORK.

Suppose that we found the SEQUENCE OF LINKS (78934, 78564, 12789, 35785).

At the end, we can assume that the arch with ID = 7500 on TMC NETWORK, corresponds to the SEQUENCE of ARCHES with ID = ( 78934, 78564, 12789, 35785). So we can add to OSM ARCHES ( ID = 78934, ID = 78564, ID = 12789, ID = 35785) the attribute "TMC ARC ID" with the value: 7500.

  1. Can you tell me what are procedure to be done for points 2 and 3 by using QGIS and PostGIS, pg routing. enter image description here

1 Answer 1


Map-matching points is usually way more complicated than taking the closest road. You can have your closest point on a road close to the one you want on the map but really far on the network (for exemple a parallel road, or a perpendicular road). When you try to take the resulting path it will be really far from the original road.

When you try to merge 2 differents type of road network, it's even more complicated, you can have differences in your geometries (the way points are placed on straight lines or on curves for example, but also the number of lanes, ...) that makes it really complicated to even compare the 2.

If you want to map-match one geometry on the other, maybe one lead would be to look at map-matching tools like OSRM, and "simulate" a trip by taking points on your first geom to map-match it on the second. I think there is also QGIS tools if you don't have much data.

One other lead would be to try to decompose your 2 networks in similar pieces, for exemple piece of road between 2 intersections, and try to match each other by using there size and global distance (for exemple using ST_Max_Distance and find the minimum). You shouldn't use the OSM ways for example, because they're not consistent in the way they are cut (they're made primarly just to store data, not to build a network). Also note that doing that, you can have differences for exemple if a road is missing, or when one of the network contains all the lanes and possibilities of an intersection and the other doesn't.

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.