Oooh - I can ride down that track...

Screenshot of the Osmond app showing my GRM geojson data

England and Wales have a somewhat arcane but interesting set of laws around what tracks are rideable by motorcycle. Some of them are nice simple lanes that could be ridden on any motorcycle by anyone. Others appear to be just a jumble of rocks that need a superstar to ride.

I must come back and write more about the laws but what interests me right now is being able to identify those rights of way and being able to navigate along them when I'm out for a ride.

Each County Council is responsible for the maintenance of a set of "definitive maps" that define rights of way and they are generally publicly viewable. However, they way this is done is not consistent across counties.

The awesome Trail Riders Fellowship (TRF) maintain a curated single copy of all these definitive maps and make it available to members in the form of an online slippy map; the Green Road Map (GRM). It's a great resource and many people sit at home, consult this GRM resource, and create a route on their sat nav device to follow later.

I'm not most people.

I wanted to be able to take the GRM with me, in its downloaded offline form, displayed on my sat nav device, all the time. I wanted to be able to wander off down these rights of way without needing to plan at all. So, I built the tooling to do exactly this.

Now, as a note here. I will not be telling people how to do this in detail. I won't be providing a copy of the data that the TRF give as a benefit to their members nor will I be describing exactly what I did. I do hope the things I do talk about, though, are interesting and might even lead to the TRF doing something similar - I'd be delighted to help with that!

The GRM slippy map is based on a js library called Leaflet and it displays a Ordnance Survey map overlaid with a geojson file that contains all the managed rights of way. My task is to:

  1. Decide on a satnav app to load the geojson onto in an offline form
  2. Process the geojson data into an offline map layer that works with the satnav app
  3. Tell the satnav map how to display the custom data included in the geojson data

After a lot of research, it turns out that apps on iOS (I use an iPhone) that are capable of displaying custom maps are few and far between! I settled on OsmAnd eventually, mainly because it is Open Source and  has a great community behind it that is suspected I would need to call upon.

A rather fabulous additional benefit was that they supported Apple CarPlay and a number of motorcycle specific CarPlay devices have been appearing with the large screens that could make trail navigation a pleasure on the bike.

One does not simply display geojson on an OsmAnd map

Now, OsmAnd does not simply display geojson data as a map. I would need to process it in a manner that would allow it to be displayed along with other map layers they use.

I would need to process the data contained in the geojson file into Open Street Map (OSM) format and then finally into a compressed format suitable for OsmAnd know as an .obf file.

This processing is done in two stages. First we load the geojson file into the OSM app, JOSM. This is a Java app that understand quite a few data formats but happily outputs OSM data and can upload those to Open Street Map themselves, if you happen to be suggesting changes to the map. We're not uploading anything, just using this app for our own purposes.

Whilst I created my own little "mapcss" file to make it look pretty, you can easily see the geojson data in JOSM:


You can see that one of the rights of way I have clicked on has its data displayed in the app sidebar. This includes a fair bit of information but the key one for me is the "class" tag as it tells us whether the track is open for full access, has partial access (such as two wheeled only), or has a Traffic Regulation Order preventing access, either temporarily or permanently. I want my map to eventually highlight this data using colour in a similar way to the GRM. It's not normally wise to simply use colour as that creates an accessibility concern but I'm not colourblind (I dress like this intentionally!) and I'm not making this for anyone but me.

At this point, I took a little "executive decision" to make life simple for myself that is to add a highway=proposed tag that will ensure that my satnav will not use this data for routing. You know, just to make it easy. Later, this will mean actual proposed highways appear on the map in a kinda light grey. I find this interesting to look at but only as an aside benefit to the work we are doing here.

Right clicking on the geojson data and saving it as a .osm file creates the OSM compatible file we need for the next step.

As it happens, I'm now investigating the fact that JOSM can be used entirely from the commend line - there's no need to actually use the windowed UI to do all this. I'm the kind of person who weirdly spends most of their time on her Mac at the command line, in its UNIX internals, so this makes me happy.


We now use a utility app OsmAnd provide on their GitHub; OsmAndMapCreator. This is another UI and CLI tool that we use to process the .osm file we have created in a way that dramatically reduces its size and processing overhead for the app once uploaded.

OsmAnd community members were super helpful at this point, describing how I need to tell OsmAndMapCreator about the important data in our .osm file that isn't "standard" OSM data – the class tag describing the various levels of access.

We detail the special tags in the app's rendering_types.xml file as follows:

<type tag="class" value="full-access" minzoom="9" additional="true"/>
<type tag="class" value="partial-access" minzoom="9" additional="true"/>
<type tag="class" value="temporary_tro" minzoom="9" additional="true"/>
<type tag="class" value="restricted" minzoom="9" additional="true"/>
<type tag="class" value="link_road_with_access" minzoom="9" additional="true"/>

And then process the .osm file into an OsmAnd friendly .obf file. This again can be done from the command line.

Finally, we need to add the outputted map (about 8MB for England and Wales) to the maps on the OsmAnd app.

But nothing displays! We need to tell the app what to do with our special data...

OsmAnd provides a whole bunch a base map styles and these exist as XML files. I really, really don't like XML but needs must.

I like the look of the "Offroad" map style so I took a copy of the xml file that produces that style and added a few lines that look out for our special data in our map and display it according top our needs:

<renderingProperty attr="grmMode" name="TRF Green Road map" description="Should we display the TRF Green Road Map (GRM)" type="boolean" possibleValues="" category="details"/>

<!-- Rachel trying to highlight proposed routes. -->
<!--                                             -->
<case tag="highway" value="proposed"> 
  <case minzoom="4" strokeWidth_4="14" strokeWidth_5="16"/> 
    <apply_if grmMode="true" additional="class=full-access" color_5="#00ff00" pathEffect_5="10_3"/>
    <apply_if grmMode="true" additional="class=partial-access" color_5="#00dd00" pathEffect_5="10_3"/>
    <apply_if grmMode="true" additional="class=temporary_tro" color_5="#0000cc" pathEffect_5="10_3"/>
    <apply_if grmMode="true" additional="class=restricted" color_5="#bb0000" pathEffect_5="10_3"/>
    <apply_if grmMode="true" additional="class=link_road_with_access" color_5="#bbbbbb" pathEffect_5="10_3"/>

Once we have edited the file and uploaded it to OsmAnd on the iPad, as if by magic, our routes appear!!


An on iPhone...


And I can now ride around the country, disappearing off down legal trails whenever I like!

So, what's next? Well, I would like to improve the automation of this, so that I can get it down to simply running a script. I think it can be done. I would also like to include more data as a clickable item on the map, especially as TRF members have added detail about the trails on the map - remember how some of them need superhumans to ride? That's not me.



https://mastod… (not verified)

1 month 3 weeks ago

@rachel Nice!I should probably join TRF to get access to those maps. I've no intention of taking my big BMW down most of those trails without knowing exactly what they're like in advance - I've been caught out too many times on my push bike, at least I can carry that if necessary - but it would be nice to get some ideas for trails to check out.