 I'm Henry and I'm going to speak about creating GPX tracks from cycle routes in open street map. So I'll give you a brief introduction to the me and the problem I'm trying to solve, a little bit of an overview on open street map data and then I'm going to speak about how we process cycle routes from that data. Then finally I'm going to give some examples of completed cycle routes and then speak about some of the challenges I encountered and some of the next steps. So as an introduction, I'm Henry, if you want to contact me, Twitter, LinkedIn, I actually work for a company called Citerra which we make a device to grow human and animal cells so it's quite far away from what I'm speaking about today but something I really really love is cycling and I use cycling every day as a way to get to work but then at other times cycling it's less of a to get to a destination, it's more about of a journey. And so here is two examples of some of the amazing cycle routes in Europe. This is the Danube cycle path and this is a very long route in Italy. So an issue that comes when trying to follow these cycle routes is often the signage is very poor. In the UK you get these stickers stuck on lampposts and then people peel the stickers off. Sometimes the sign is 20 meters down the road that you've meant to turn down and then once you're off route it's quite hard to recover. There are some amazing resources out there that help with that. Open Cycle Map is an excellent website where it shows all the regional and national and international cycle routes but it's not always the easiest to follow on your phone. So I'm going to present Open Cycle Export where given a country and a cycle route reference you can take the data from Open Street Map and then download it as a GPX file. So why a GPX file? GPX files are portable to many different devices so you could follow the route on your watch, on your cycle computer or there's many many apps available that you can use to follow GPX tracks. So the next section is to a little bit of an overview of Open Street Map data with relevance to cycle routes. So a lot of this will be familiar to people here but as a quick overview the Open Street Map data model consists of nodes which is a coordinate in GPS space, ways which is an ordered collection of nodes which could represent a road or a footpath and relations that are collections of nodes or ways and that's how a cycle route is stored. So a cycle route is stored as a relation where they're just stating all the different ways that make up that cycle route, so all the different roads involved. So I thought great it'll be very very easy to take the data from Open Street Map and download it and make a GPX file. So I used a function called line merge which is part of the shapely library in Python that's meant to take lots of different lines and put them together to one continuous route. However as you can see the route that came out is not one that you'd want to follow and that's because these large inconsistencies and to drill down have a look at where these inconsistencies originate from. Here is an example of one of the issues. So this is a roundabout near Peterborough and obviously if you're trying to take a continuous route the shapely line merge doesn't know which section of the roundabout to follow. So that's an issue that needs solving in Open Street Map data and also what we can see from looking at why this occurred is the colours represent different ways that make this up and the green way is the roundabout and then there's the two joining roads. So actually there's no point that joins the ways of the joining road and the roundabout. So there's two problems here. One the line merge doesn't know which track of the roundabout to choose and two the ways the roundabout way doesn't join an end point to the ways that join the roundabout. There are other issues in some of the cycle route data. For example here we again get the same problem where right at the top where the yellow joins the green. This is a joining point of two ways where that doesn't correspond to an end point of a way. So that's hard to route. In addition there's just a complete gap. So line merge completely falls down in the scenario where it's trying to resolve a route. So that was a little bit of an overview of what the data is stored in Open Street Map. I'll now talk about how we can process that data and try and result in a cycle route that you can then follow on one of your mobile devices. So as a very basic overview to the tool it uses the Overpass API which is an excellent way to query Open Street Map data and then you don't have to download any big binary files so you can download just what's relevant to your use case. So here we're downloading a particular relation for a certain cycle route and this comes with all the ways and nodes that make up that cycle route. We then process the ways as I showed before with the roundabout. There's places where the ways join but that doesn't correspond to an end point. So we need to split the ways by the points that they join other ways. And then once we have those waypoints where they all join we need to do some processing to work out the best way to go between them. And finally once we've done that processing we then create a route from that setup of waypoints and finally we can download a GPX file from that. So processing ways. We find all the places that ways intersect and we call that waypoints. Then we split the ways at all the waypoints so that we have subsections of ways. Then we create a cost matrix between all these intersections. And so cost is something that we've defined as a distance, the distance of the line between two points, times by coefficient. And so a coefficient for a way that is primarily for cycling along, the coefficient is very low. We choose a one coefficient for a way where cycles are permitted. A road with a specific segregated component of cycleway will choose a cost such as two. So a little bit more penalizing that route. Or for just a generic road that has no cycle provision, a cost of 10. And finally for a road that it's maybe you going the wrong way down a one way street. So it's an impassable road but there's still a connection. We'll choose a coefficient of 100. So we're really, really trying to penalize. But the whole purpose is we want to, whatever the data holds, we want to be able to get a final cycle route all the way. And then identify the issues at the end. And finally we have a coefficient where there's no connection between two waypoints. And then that's a coefficient of a thousand. So it's very penalized but we still will make that jump if we need to make that jump. So that's how we build up the cost matrix. And to take that back to the example with the roundabout here. These are two directions between the different waypoints. Because sections can only allow you to pass one way. This is a roundabout in the UK so we have to go around it clockwise. Therefore, the join to the roundabout, it's a two coefficient each way. To go around the roundabout clockwise is a two coefficient. But to go around it anticlockwise is a hundred coefficient to penalize that option. And again the way on the other exit to the roundabout is two both ways. Because it's permitted but it's a road, it's not specifically for cycling along. Then we have this cost matrix and we want to create a route from it. So we've downloaded a relation. And the first thing we need to do is work out where the route is going from and to. Initially what we do is we just take the furthest two points. This falls down in a number of different scenarios. But initially it works for trying to get the longest route available. And then we use Dijkstra's algorithm to find the shortest path between these two furthest points. And we create a route in both directions. Obviously one way you'd want to go one way around the roundabout. And the other way you want to go the other way around the roundabout. So some examples of the created route. You can't see the blue line when it's on the entrance and exit to the roundabout. But if you were coming from this point to over here, you'd go clockwise around the roundabout. And if you were coming back, you'd obviously go clockwise but the other way around the roundabout. So this is how in a very low level example, we choose the correct direction to go along the different options for the road segments. For the example where we have a complete lack of connection, we choose what is close to being the, what looks to be almost the closest. To my eyes, actually this one looks closest. But so this is not actually a way in open street maps. But the routing algorithm has done the jump to try and find the best available option to try and make up the route. So that was some examples of at a very low scale what the routing algorithm does to weather the slight inconsistencies in the data. Here's some examples of some completed cycle routes. So this is the RV4 in Belgium. And you can't see on this image. But maybe if I zoom in, there is a number of different, there will be sections in here that resolve one way sections. So for example here, this route actually has a version that goes from Brussels and a version that comes to Brussels and resolves the one way sections in it. So that's an example of route in Belgium. There's also some fairly long routes. This is one in France that follows up the Lot Valley and another example of a route in the United Kingdom. If you'll notice here, what's quite alarming is these completely straight sections. It is the discontinuity of either the route or the data that represents the route. So I think the downloaded GPX files have to come with a caveat of declaring what percentage of the route is actually following ways because that wouldn't be achievable to follow. But we're trying to make a very tolerant routing algorithm so you can, from a particular national cycle route, you can get an overview of the whole journey. So I had a number of challenges that are still present and got some next steps to look through, which I'd really welcome for feedback and help on because I think there'll be quite a lot of time for questions and suggestions. At the moment, there is no elevation data for the points on the route. And if you're trying to plan a route on your bike, in the apps, they have really, really excellent elevation profiles. But this elevation profile would be entirely zero. I've tried to use Open Elevation API, but haven't been successful in getting the responses accurate. Often it just times out. So I'd like a way to get elevation data for these route downloads for the GPX files. In addition, I'd like to use a correct spatial reference system. At the moment, it does what is the horrendous thing really. It uses just the GPS, the latitudes and longitudes in order to find distance. It doesn't use the haversine function, which is a huge limitation. But I wanted to find a nice way to change between coordinate reference systems or spatial reference systems. So I'd welcome thoughts and feedback on that. And the continuity of cycle routes or route data, as we saw in the example on Route 2 in the United Kingdom, there was massive sections where there was gaps. So this is either a process of trying to encode that data into OpenStreetMap or to see why the route doesn't actually continue in reality, which is also a big concern. And finally, finding the true start and end points. If a route, say, did a horseshoe, this process would not result in the whole route because it would just choose the two furthest apart points. And so it would miss almost half the route in that case. So those are some of the current challenges. Next steps. I'm thinking that the best approach to share the generated GPX files is on GitHub releases because that means that they're always available online. And so because they take a little while to process, it then doesn't require someone to have to wait for that processing to download them. I would like to declare which routes are not continuous. So you have a percentage of the route that doesn't actually follow ways. So you know that in advance when you're trying to use these GPX files to go on a long adventure. And additionally, because often people won't necessarily want to follow the 200 miles of route as a continuous section to split the routes by the towns they pass through, which is an easily achievable thing with the Overpass API by looking at whatever towns they pass through and then working out little sections that you can then download. So those are some of the next steps available. And we've got a good period of time for questions. So I'd love any questions or comments or suggestions on how to solve some of the challenges. I'm sure it will be easy for others. Did you need to incorporate some country specific? So in order, the question is around incorporating country specific knowledge about routes. So I didn't include any country specific knowledge about the routes. But I did use the OpenStreetMap tags regarding whether something is a one-way route or one-way permitted, well, two-way for cycles apart from one-way for cars. Kofi? Yes, for our open companion situation, because in Brussels, I know this example. Very good situation. There are private streets. There are also walks in some streets. So you know the little ring in Brussels, they are made bicycles, but bicycle pass in this little ring. But after it, it will be very nice. But now, there is some section, it's very absolutely not convenient for cyclists during the walks. And so are you taking this in account in your... So the question is regarding the roadworks on a route and how that's taken into account. If there isn't data in OpenStreetMap for it, at the moment I won't take into account for it. But if you know of some tags in OpenStreetMap that encodes that information, that would be very useful to put into the tool. I'd like you to go back to a lot of... not all, but a large quantity of the one-way roads allow for bicycles on the other road. The Google navigator always blocks. I have read on OpenStreetMap how they say that if a country's standard is to allow opposing flow for cyclists, it then is, as opposed to tagging it when it's allowed, contra-flow for cyclists, they'll tag it if it's not allowed contra-flow for cyclists. So that's a very good point. I need to incorporate that because it was very UK-focused when I was originally building out the tool. Cycle routes, we're trying to cycle routes. If you want to carry your bicycle, it's okay. So this is... Sorry, I'm going to be a little bit blunt. I only want questions. Very concise questions, so you can answer in a concise way. This... I'm terribly sorry. It isn't a question. It's a software recommendation for projecting your cars' graphic coordinates. There's a thing called Libproj. You want Libproj... Libproj. Libproj for excellent. Great takeaway. No, no, you're helping this whole day this place to be... No, no, no, you are. Go on. I was going to ask why you don't get back data from the cyclists about the elevation. Because almost all people start their cycling. So you get from... you can use travel routes and get data from them about the elevation of different routes. And potentially even compare the GPX track of their route to the route to see if there's any roadworks on the way. Yeah, but it's given in the... They're using their own digital evaluation model. Yeah. Okay, you can take this offline. Yeah. That's a definitely... So I think I'm across CycleStreets.net. I have done. Right, okay. Because they have a lot of these questions. They have spent about a decade dealing with all these problems of cycle routing on the OSM data. So there's probably a lot of good ideas you can steal out of that to get less shitty routes. Okay, great takeaway. Maybe since they remarked there was a new project which is called CycleOSM, which replaces the depredated open cycle map. And which... CycleYSM. Okay, you learn more from them than they do here. Works well for me. That's something that I think is an important part of the project. So when I have the website available to download the GPX files, it's also a case of saying hearing consistencies in the map. Because if you can't route it from a cycle... If the cycle route is already saying you can get to these two places, then if you can't route over a certain point, then it's an issue with the ways, which might affect then car routing on top of OpenStreetMap. Okay, the Dutchman in the back. I didn't, but I'd really like to see it. What's it called? So there are lots and lots of things available to say, I want a cycle-friendly or a fast route between two points, but to download just a cycle route. Okay, I'm going to cheat. Yuri, could you come forward and sort of plug yourself, your laptop, or both in? Yes? Yuri? Okay, next question. Where was that, Yuri? With regards to the elevation model, did you look into government or city applications of open data? They often have their elevation models published online as open data and that you could use... And that would be for a city level or for a country level? Depends. There's a lot of open data. Thank you. You had a question. Have you been thinking about incorporating heat maps like this to use data which parts are most used? I haven't thought of that. That's a really nice feature, I use it all the time. Gosh. You have so much to think. That's another question in the back, sorry, the last one. I haven't seen Cycle.Travel before. Oh, brilliant. Okay, the gentleman in the... One but last row. Good question. Is it possible to download the intermediate data that has the matrix weights so that you can perhaps add preferences that can be taken into account in that sort of... like the shortest path, such as, for example, you would prepare specific types of the routes or extend it to add, like, ancient things to this data? Currently the matrix is not available to download, but you'd really want to get in just before that step, before the coefficients are applied. So then you could provide your preferences. So perhaps an extensible version where you can choose your own coefficients for different sections of route would be a good idea. Okay, the last one. Thank you for having upgraded me from... It's all okay. Thank you for something else.