The Great Polish Map of Scotland Revisited

A lot of progress has been made since my last visit: Visiting the Great Polish Map of Scotland

This time I had a bit more time, staying overnight with the very accomodating girlfirend at the Barony Castle Hotel. The steak was excellent, but the sauna was not very hot. Overall a good experience though.




As you can see from the photos restoration works are in full progress.


And dontains can be made to the worthy cause at:


For a view of the way up to the map, see my first post on Mapillary:

Self Hosted Leaflet Photo

There is an excellent plugin for Leaflet called Leaflet.Photo.

The plugin was created by Bjørn Sandvik. See the full post:

The plugin has a number of examples that show usage with image hosting platforms, like Google Photos and Instagram, which have assicaited API’s for returning information about the image in question.

I was however keen to host the sollution completely myself, so simply have a folder of images that would populate on the map if they had exif GPS information.

I have created an example available on GitHub:

Simply download the full repo:

Copy the local_file_example folder. Replace the images in the Photos folder with your own photos. Load it onto any php supporting webhost.

Like: BlueHost

Or for more advanced users, the examples below are on: DigitalOcean

And link to the folder with the index.html



GIS to CAD using ogr2ogr – Part 3 – Point Annotation to Text in CAD

GIS to CAD using ogr2ogr – Part 1 – Shp to DXF with Contour Data
GIS to CAD using ogr2ogr – Part 2 – GML to DXF with OS MasterMap

MasterMap Topo Sample Data:

OS MasterMap has an annotation layer, which is simple to symbolise in a GIS program. But becomes more difficult in CAD software.

With ogr2org, when writing a DXF file, if you have an input point geometry, which has an OGR_STYLE attribute, it will be written as a text geometry when opened in CAD.

So for our MasterMap data we have one layer we want to convert to text:

So for this we are primarily interested in “textString” and potentially “orientation”.

Lets see the layer as points first as a baseline:


Zoomed in:


But lets try that as text. We will keep this simple and only take into account orientation and to a small extent height. Lets look at orientation:

Orientation – The orientation of text or symbol features for cartographic placement. This is measured in tenths of a degree anticlockwise from due east (0–3599).

So conversion to degree will be simple. Orientation/10

We can also take into consideration height as a multiplier.

And “textString” stores the text itself.

The command:

Full extent:


Zoomed in:



Since this is run in windows, through the regular console, the escape character for quotes is two quotes “”‘. So a combination on ‘ ” and “”‘ we can accommodate all the required quotes.


Font: Arial

Size: Multiplier of the height field, I am not sure what the units are, comments appreciated.

Text: textString column

Align: In degrees

Position: the OS position and the ogr2ogr style position are slightly different, so better placement could be achieved with some pre-processing

GIS to CAD using ogr2ogr – Part 2 – GML to DXF with OS MasterMap

GIS to CAD using ogr2ogr – Part 1 – Shp to DXF with Contour Data
GIS to CAD using ogr2ogr – Part 3 – Point Annotation to Text in CAD

For this example we are using Ordnance Survey MasterMap Topology Layer data.

MasterMap Topo Sample Data:

Now we know that we can maintain an attribute through layers, as we saw in the shp to DXF example, the export of MasterMap should be straightforward.

Let’s first see what the GML file contains.

So we have 6 layers in total.

For MasterMap in CAD we will be mainly interested in CartographicText, TopographicPoint, and TopographicLine.

Lets start with TopographicLine.

Nothing too useful.

A bit more details:


For this feature the “descriptiveGroup”” seems the most useful, and from reading the os-mastermap-topography-layer-user-guide.pdf the best would be either a combination of descriptiveGroup and descriptiveTerm or using the featureCode. Since this is a simple conversion we will just use a combo of descriptiveGroup and descriptiveTerm to create our DXF layers.

I will be using || for concatenation, which works with the SQlite SQL dialect.


Not quite. Seems to be missing geometry, perhaps a SQL select issue.

This can be tested with:


So we do not have any geometry. Lets bring that in.

Geometry looks good:


But if we check the attributes in QGIS:


We can see that all of the attributes that are not 0 have both a descriptiveGroup and a descriptiveTerm, which was not what we can see in the ogrinfo summary. So our SQL statement is cutting some out.

Try again:

!!remove the !! and the space from the word after, the word in question breaks WordPress.

Looking better:


But it won’t open in AutoCAD DWG TrueView. Lets try running it through a ShapeFile format first before the DXF conversion.

!!remove the !! and the space from the word after, the word in question breaks WordPress.



No indication of why a direct GML to DXF conversion would hang TrueView, and your mileage with other CAD software may vary. But ShapeFile is a very simplified geometry format, so perhaps running through that helps with some more complex geometry in the GML. Hard to say with no errors from TrueView, just a stuck program.

Repeat for point:

!!remove the !! and the space from the word after, the word in question breaks WordPress.

GIS to CAD using ogr2ogr – Part 1 – Shp to DXF with Contour Data

GIS to CAD using ogr2ogr – Part 2 – GML to DXF with OS MasterMap
GIS to CAD using ogr2ogr – Part 3 – Point Annotation to Text in CAD

The power of GDAL, and specifically ogr2ogr is pretty impressive. This conversion is from shp to DXF, which is a somewhat universal CAD format so further conversion should be possible.

This post will cover contour export while maintaining 3D elevation, in addition to contour values as layers in CAD. The data used is OS terrain 50.

OS Terrain 50:



Contours in 3D:

With the -zfield creating the 3d elevation.

Great result:


The alternative is to just store the z-value as layers.

Layers work great:


With the ogr2ogr DXF driver, if you have an input column called “Layer” then it will be used to group features as a layer in DXF. We use a SQL query to achive this. Prop_Value is the height field in my input data.

And putting them all together:

Result not as expected, flat output:


Adding our SQL select statement removes our zfield attribute as such ogr2ogr cannot access it. Lets resolve this:



Layers and height.

UK Rail Network by Agency and Parent

I created a post of the UK rail network some time ago and have been meaning to return to the subject.

This iteration is in Leaflet and will run weekly. The network is generated direcly from the UK rail network timetable file in GTFS format downloaded from:

The network is still generated using a station to station methodology, so the next step will be to incorporate an actual network and run it trough PGRouting. The logic for ownership can be found at:

If there are any issues or inconsistencies, please let me know, preferrably through the GitHub issues page: GitHub Issues

I am very happy with the overall result and all the hosting is done from scratch using a virtual server from: Digital Ocean

A good learning experience with NGINX and mobile forwarding.

As a final warning, the mobile version is not very good, if viewing on mobile and interested, please try on a desktop. Sincere appologies for that. Leaflet may not be the best mobile platform, although it is probably due to my inexperience with it.

Full Page Link

UK Rail Map by Operator and Owner:

State of the Map Scotland 2015

State of the Map Scotland, the OpenStreetMap conference is taking place this week/weekend in Edinburgh.

Saturday – Community Day:
Day 4

Sunday – Workshops:
Day 5
-Covers for example 3d printing.

Registration is still open but closing soon, it is free but required:

There are some interesting talks going on, and should be a great day of mapping.

Map Action

A slightly more personal post.

Myself as part of a team are raising money for MapAction.

MapAction, can be a tough sell as a charity. Why would you donate to a charity which just makes maps? While a valid question, it raises the whole concept of why does GIS matter? While the Red Cross, World Food Program, and other large charities deliver aid to those in need, they also need logistics to deliver this aid. This is where MapAction can really step in. Staffed by mapping professionals, they can help print maps, re-route transports, and keep maps up to date on the ground. This ensures that the aid from NGOs get to where they need to be, in the most efficient way possible.

GIS professionals have a specific talent, one for all things spatial. While a niche talent, it is critical for the projects we work with. The same goes for MapAction, they are the GIS consultants of the volunteering world, but instead of charging for their services, it is staffed by volunteers. Their operational costs mainly come from the logistics. Shipping a plotter to Nepal in order to pint maps so that other charities can deliver their supplies to those areas that need it the most.

In support of MapAction, I am taking part in two events:

Pedal For Scotland:

Taking place last weekend, it was a 50 mile pedal from Glasgow to Edinburgh. To warm up I decided to cycle from Stirling to Glasgow the day before.

Route over the two days (83 miles in total, day 1 yellow, day 2 purple):

Excellent day with the sun shining the whole distance!

Total Warrior:
This weekend it will be: Total Warrior

A 12km long obstacle course, full of electic shocks and obstacles through Scottish Lochs!

If you have enjoyed this blog, perhaps gained some value, please consider donating though this link:
MapAction Page

Or Supporting MapAction directly:

Thank you!


The Total Warrior experience:

Excellent production value from: Mallard Productions