Sunday 18 August 2013

Rights of Way

I saw mention of some open data about rights of way in various English and Welsh counties on http://www.rowmaps.com/. I downloaded the shapefile and took a look at it. The rights of way are stored as MultiLineString because a few are broken into two sections, though most are single lines. I wanted to see how they relate to any rights of way in OSM. I am not sure about the licence - there is no statement from East Riding of Yorkshire council about the licence so I cannot load this in any way into OSM. I do have other reservations about the data too, but more of that later.

My web site provider, like many cheap one, provide PHP and MySQL to create a site. I have not used the spatial functions in MySQL before so I decided to see how well they work and in the process make an overlay for an OSM map with these rights of way on it. I created a simple python script to load the data into a very simple MySQL table, loading the MultiLineString into a geometry field. The functions that work with the geometry fields in MySQL are much less capable than PostGIS in PostgreSQL. MySQL allows the geometry be to selected based on a bounding box. This is ideal for me as I want to select the items that show on a section of map that is currently being displayed. Its bounding box is easy to find. The MySQL function is MBRIntersects. The bounding box of the current map being displayed is converted into a polygon and this is compared to the bounding box that encloses each of the MultiLineString in each row and if the two bounding boxes intersect then the row is selected. This means that some part of the right-of-way that the data represent should be displayed on the displayed window of the map. So how to display it?

I like the Leaflet library to display maps and Leaflet has good support for displaying geoJson as an overlay. When the map is first displayed or scrolled or panned I use the new bounding box to create an ajax request which returns the data selected as a geojson. This is a PHP script which uses the bounding box to convert into a simple SELECT statement and parses the returned data into geoJson. The existing overlay is cleared and the freshly returned data are added to the geoJson layer.

A geoJson layer is a collection of features, in my case each feature is a MultiLineSegment from the original shapefile. It also has properties which we got from the shapefile too. As each feature is processed the style can be processed dynamically. In my case the footpaths are made red, the bridleways made green and the byways are blue; one of the properties is the right of way type. I also use the onFeature event to call a function that adds an onClick event to each feature. When a feature is clicked the properties can be displayed in a side bar. I added a hash to the address line too to match the standard OSM map. You can see the result here.

So now I can compare the OSM map with the data from the council. The first thing to say is that there are a lot of rights of way on the overlay (1762) and a significant number are clearly missing from OSM. On closer examination though the data does not look very accurate nor very up to date. In West Ella a footpath seems to go through a couple a of houses. Elsewhere a local footpath was moved many years ago, but the old route is still shown. OSM shows the surveyed and signed route. There are other anomalies too.

Having the overlay does provide a good place to start surveying what is really on the ground and signed, but loading the data verbatim doesn't look a very good idea even if the licence was published and acceptable.

I think I may yet extend the overlay to show which rights-of-way have been surveyed and matched with OSM ways. It looks like there's some walking and cycling ahead, which in the East Riding countryside is never a hardship.

Sunday 11 August 2013

Comparing layers

About three years ago I created a simple map using OpenLayers to display a base layer and overlay some layers on it. It features layers useful to some GB mappers. From the logs I can see that it is used quite a lot.  All of the slippy maps I've created recently have used Leaflet rather than OpenLayers so I thought I should update my comparison map in Leaflet. You can see the result here.

It has base layers of MapQuest open, the Standard OSM layer or MapQuest roads. For overlays you can choose from the ITO World tiles of OS OpenData Locator anomalies, the OS OpenData StreetView or my tiles showing the Office of National Statistics postcode centroids. Whichever of the overlays are shown you can move the slider (top-left) to change the opacity to make the base or overlay readable.

The browser address line shows the constantly-updated location and zoom, in the new style of the OSM landing page. This makes bookmarking the position easy. There is also a lat / lon display bottom right which shows you the location the mouse is currently pointing at.

I intend to leave the existing oscompare unchanged and maintain this new leaflet-based one in the future. If anyone would like any other layers or if there is any problem please comment.

Thanks to MapQuest and ITO World for their map tiles and their processes for updating them, thanks to Ordnance Survey for their OpenData and thanks to the OSM admins who manage the OS StreetView tiles.