NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi there!

I have collected bus GPS data and I want to draw a route of that bus according to that GPS data on a map. I tried to use available services that provide Directions API. But there I can either choose car, bicycle or pedestrian as a travel mode, and those services try to avoid some places, where the bus definitely goes, but it is either not allowed to driver there by car or the route under construction. Pedestrian type doesn't work for me because the services draw a route next to the road, but not over it. What I basically want is to draw a line on the road between multiple GPS points, but I don't want any "smart" functions that such services provide.

Don't you have any suggestions how it can be done? E.g. get a pice of road where GPS coordinate point to.

UPD:

Here is the example how direction services draw a route and how it should be. Blue line is how the mapbox draws the route. Red line is where the actual route is located.

alt text

asked 07 Apr '19, 17:16

RokrVPV's gravatar image

RokrVPV
26113
accept rate: 0%

edited 07 Apr '19, 19:53

1

Sorry, it's not immediately clear what your end goal is here and how it involves OpenStreetMap.

Are you trying to add a bus route to OSM and then create a map from that data that shows the route?

Are you trying to find a router that will get you from A to B using public transport data? That's unlikely to be OSM-based as although bus routes may be in OSM actual timetables won't be.

(07 Apr '19, 17:27) SomeoneElse ♦

"Are you trying to add a bus route to OSM and then create a map from that data that shows the route?" - yes.

What I have is GPS coordinates of a bus that traveled along its route. Now I want to use these coordinates to draw a bus route. Finally, I would like to have an encoded polyline of the route so that later I could use this polyline to show the route on a map.

To achieve this, I tried several Directions API services like mapbox or graphhopper, but they don't always draw a route correctly, because some roads are not accessible by car. Instead, they try to navigate around such roads. I will upload picture to the post to show what I want.

I believe that OSM has stored roads as a data. So what I am thinking about now is e.g. try to get a polyline of a part of the road by GPS coordinate and then glue these polylines together to get the whole route. Or maybe there is a way to force such Directions services to draw what I want. I also know that OSM has bus routes, but they contain partially old or wrong data so I can't use it.

(07 Apr '19, 19:47) RokrVPV

You have two options:

  1. Simply draw your GPX track onto a map. This can be done with standalone programs like those mentioned by Gys de Jongh or with QGIS, and alternatively with online services like UMap. The advantage is that this shows exactly the path you have recorded. The disadvantage is that it does not take the road network into account at all, so if you have some recording errors or missing points, your track will not follow the road nicely.
  2. Use a "track matching" software that finds the most likely route travelled by a vehicle when you have a GPS track as input. Popular routing engines like GraphHopper an OSRM offer this feature, but as you have already seen, when you use the standard routing profiles they will refuse to route over roads that are not allowed for cars. But if you install the software yourself then you have full control over the routing profile, and you could for example take the car profile and remove all the rules about "do not use a road that is only for buses" and so on. For example, in OSRM the code in https://github.com/Project-OSRM/osrm-backend/blob/master/profiles/car.lua#L82 means that everything with access=psv will not be considered; if you drop that line, the router will consider such roads as well. (You might need to make a few more changes than this to achive the desired result but it's a start).
permanent link

answered 07 Apr '19, 23:38

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

That is an option, thanks! I'll need to dig into it.

(09 Apr '19, 20:02) RokrVPV

Marking the answer as a correct. I was able to do that was suggested by @Frederik in the 2nd point. The only problem I see now is that when I set overview=full for route service, the points are a bit shifted from their correct location and don't point to roads, but next to it. But I am able to construct a route if use geometry from each step by setting steps=true in the request.

(01 May '19, 21:17) RokrVPV

(answering the points in the comment "What I have is GPS coordinates...")

Once you've added a bus route to OSM you'll be able to create a map that shows that bus route on it. The route will get added to OSM as a relation, and whatever you use to create a map will need to display that. See for example this example on the OSM website.

It doesn't make sense to expect a router (foot, car, or bicycle) to follow a bus route.

Depending on what sort of "map" you're creating you'll need to do something different to display relation data. I wrote this diary entry ages ago about doing it in a style similar to OSM's OSM Carto style.

permanent link

answered 07 Apr '19, 21:40

SomeoneElse's gravatar image

SomeoneElse ♦
36.9k71370866
accept rate: 16%

Hi RokrVPV, you can do that in BaseCamp https://www8.garmin.com/support/download_details.jsp?id=4435 or in QMapShack https://bitbucket.org/maproom/qmapshack/wiki/Home There you can draw whatever you want, or even just import your Gpx trace, and print your map. What you want is not possible in Openstreet map. Here buroutes must follow established roads and not Gpx traces. You can use your Gpx trace only as a guide to edit the bus route. If the roads are not present yet, you have to draw those first from an opensource. Bus routes are not for the faint of heart though : https://wiki.openstreetmap.org/wiki/Buses

Gys

permanent link

answered 07 Apr '19, 19:00

Gys%20de%20Jongh's gravatar image

Gys de Jongh
7131514
accept rate: 16%

Thanks! I'll have a look at these tools.

(09 Apr '19, 19:59) RokrVPV
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×223
×179
×41

question asked: 07 Apr '19, 17:16

question was seen: 7,217 times

last updated: 01 May '19, 21:18

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum