Donald Noble’s Site

Probably only interesting to me

Plotting GPS tracklogs to UK National Grid in AutoCAD

When out on site visits for work (as with other times), I often record where I have gone using the GPS on my phone. It can often be handy to overlay this on a CAD drawing. Until now, converting this has been non-trivial. However, I now have a reasonable, if somewhat convoluted, workflow.

I record tracklogs using MotionX-GPS for the iPhone, which allows you to export the result as a gpx file containing Latitude/Longitude pairs in decimal degrees, with corresponding elevation and timestamp.

Using the free GPS Babel software, this can be converted to a csv comma delimited list of Latitude/Longitude pairs, although still in decimal degrees. However, for UK National Grid, they need to be in easting and northings from the origin off Cornwall.

This is where I had been getting slightly stuck. And I am sure there are various solutions using GIS software, but I wasn’t finding one, and don’t have easy access to GIS software anyway.

I was using an Excel spreadsheet developed for geocaching (Waypoint workbench) to convert the co-ordinates from decimal degrees to UK National Grid, but the resulting points were offset from their true location. I suspect this is because the spreadsheet does not take into account some difference in geoid or datum1, but I’m not sure.

But, there is another piece of software available from the Ordnance Survey called Grid InQuest that you have to email them to get a copy. This appears to correctly convert the latitude/longitude from GPS to Eastings/Northings. However, in this conversion process the elevation is lost, but this is not of importance to me, and is usually rather inaccurate anyway.

A little bit of manipulation is then required in Excel to combine the eastings and northings into one column and remove duplicate points, before plotting in AutoCAD as a polyline.

Summary of Steps Required

  1. Export GPX file from GPS
  2. Convert GPX to CSV in GPS Babel, using standard parameters
  3. In Grid InQuest, File>Convert File(s)
    1. Select delimited by commas, and Geodetic (Lat, Long) coordinate format
    2. Set Latitude, Longitude and Ellipsoidal Height as columns 1, 2, and 3 respectively (although there is no data for the height in the GPX file, it still works).
    3. Set Projected coordinates (Eastings, Northings) as the output format, and append to existing files (or specify a filename).
  4. Open the CSV in Excel, and add the following formulae in the next blank columns =D1&","&E1 where D and E are the columns of eastings and northings respectively, and =IF(F1=F2,"",F2) to filter duplicates.
  5. select all the data, press ctrl+L to make a list (the data probably doesn’t contain headings) then, using the drop down arrow on the last column, auto filter then data using the condition “Does not Contain” and leave the box blank. This will give just the individual values.
  6. Select just this last column of data, and copy to the clipboard.
  7. Finally, to plot these into AutoCAD, type pl to start a polyline and press enter, then paste the concatenated co-ordinates and press enter to finish.

There is doubtless an easier way to do all of this, and I would be interested to know if you have any suggestions. But I thought I’d put this up here in case it prevents someone going though the same headaches as me.


1 The Wikipedia page on OS National Grid has a section on the differing data for WGS84 used by GPS and OSGB36 used for the UK National Grid, which might be the source of the error.

Posted: 30 July 2012, 20:54; tagged: , , , , , .


Using OS OpenData 250k maps in JOSM

It is possible to use the Ordnance Survey Open Data 1 to 250,000 raster maps as a background layer in JOSM. However, the positional accuracy of this scale of map is limited. This could also apply to the StreetView tiles, but they are readily available as a WMS layer, which is probably preferable.

The OS tiles are in the OSGB co-ordinate system, but OSM uses WGS84. However, there is a plugin that can fix this, and re-project the tiles in the correct location.

Firstly you need to register and download the tiles from the OS, if you do not have access to them. This is free, but can take a while. Once you have saved these to your computer, move the TFW world files from georeferencing files/TFW/ into the main folder with the TIF images.

Then install the Import Image Plugin for JOSM, and restart as required.

To import a tile, select ‘Import image’ from the file menu; browse to and select the required TIF image (with the TFW file in the same folder). This should be imported to the default reference system (which will be wrong, but that is changed later).

Once the image is imported, right click it in the Layers panel, select ‘Layer Properties’ then the ‘Source Reference System’ tab. Type EPSG:27700 in the search field, which should give “OSGB 1936 / British National Grid [ESPG:27700]”. You will probably want to ‘Set as Default’ so that this step doesn’t need to be repeated. But you also need to click ‘Apply Default’ at the top to re-project the image, this isn’t done when setting the default.

This should give the OS 250k raster tiles as a background layer, in the correct location with standard OSM data. Additional tiles have to be imported as separate layers, and need to be toggled when tracing at boundaries, because the images have been rotated and scaled as part of the re-projection.

addenda This should also work for any other image map using UK National Grid, where you have (or can create) the appropriate world file for the extents of the map.

Posted: 2 January 2012, 14:44; tagged: , , , .


JOSM Data Source UK Preset

Constantly typing source: OS_OpenData_StreetView when editing OSM was becoming tiresome. Therefore I hacked together a quick sources preset based on one for Spain by user Sanchi. Perhaps this will be useful for others editing OSM in the UK using JOSM.

With one or more nodes or ways selected in JOSM, simply click on “Data Source” to open a dialogue box to quickly add in the source(s) used.
screen shot

To install, open the JOSM preferences and select “Map Settings” (the 3rd tab down) and then the “Tagging Presets” tab. Click the + to the right of Active Presets, and enter a name such as “Data Source UK” and the URL http://drnoble.co.uk/files/OSM/Presets_Data_Source_UK.xml. This should be available after restarting JOSM.

You may wish to add a shortcut icon to the toolbar, rather than using the menu item each time.

Version History

  • 0.3 (2012-01-02) Current version added ‘OS_OpenData_VectorMapDistrict’ and note/fixme fields
  • 0.2 (2011-12-28) added ‘local knowledge’ item
  • 0.1 (2011-10-15) first version

Posted: 2 January 2012, 12:06; tagged: , , , , , .


OpenStreetMap editing with JOSM

I have done most of my Open Street Map editing using the free JOSM Editor, as I feel it has a number of advantages over the default, Flash-based, Potlatch editor built into the website. The feature I use most is the various background image layers, but also being able to quickly loading my GPS tracks and support for other plugins are useful too.

JOSM Imagery Layers

When editing, primarily I’ll use Bing aerial imagery (also available in Potlatch) to help align my GPS tracks and photos. However, in areas where high resolution imagery is not available, I can switch to the Ordnance Survey Open Data Street View layer1.

There are also a number of older maps which are now out of copyright, and so features such as hills (which don’t change much) can be added to OSM. They can also be useful for checking routes of old railways etc., although the alignment can easily be 50-100m out. There is a list of old map sources on the OSM wiki — however, coverage is incomplete, and sometimes the servers are not available for whatever reason.

When editing in hilly region, I sometimes find the hill shading incorporated into the cycle map useful; and again, this can be loaded as a background layer (although it can also be a bit slow to load at times). Finally, I also occasionally load the OSM tiles as a background, which at first seems counterintuitive, but can be useful.

There is also support for displaying multiple layers at once, being able to alter the transparency of each. But this often becomes very confusing, as it is not always apparent which layer something is from.

GPS Tracks

JOSM can directly load GPX files, as well as (optionally) downloading other GPS tracks uploaded tot he OSM website. I usually change the colour of my tracks, and set them as the top layer, so that they stand out against the other tracks and features.

JOSM Plugins

I have installed quite a few of the available plugins for JOSM, but the two I find most useful are:

Buildings Tools which lets you quickly draw rectangular buildings. I have configured the preferences to automatically set source="survey;bing" as this is usually the case. Complex buildings can be drawn in parts, and made into one using the shift-J join shortcut. When combined with the feature to constrain the geometry to selected ways, this is especially useful.

Improve Way Accuracy lets you realign a series of nodes with fewer clicks—especially handy when using a trackpad. Simply select the way, press K, and click to realign. ctrl+click adds a new point, and shift-click locks the movement of a specific node.

JOSM Presets

Having a much wider series of tagging presets built into the program speeds up editing IMO. Although the grouping of them sometimes seems counterintuitive, so I added the preset search dialogue button to my main toolbar.

You can also install additional presets for the types of things you are editing (such as Skiing). The One click presets are especially useful for tunnels and bridges.

I have also developed hacked together a preset for source tagging based on another similar preset for Spain. See separate post on this

I’m sure there are loads of other useful plugins/presets etc. out there that I am not aware of, but these are the ones I have been using to date.


1 A nominally 1:10,000 series of maps, not to be confused with Google’s street-level photography.

Posted: 2 January 2012, 11:57; tagged: , , , , , , , , .


OpenStreetMap

Over the past few months I have been getting involved with the OpenStreetMap project — a Wikipedia style map that anyone can edit, and use for whatever they want.

I had downloaded a few map apps for my iPhone, which used OSM as a background. I spotted a few errors, so looked into how to correct them.

I had looked at OSM a few years ago, when it was just a series of straight line roads connecting the major towns. Since then it has improved significantly, and now has most roads accurately located, as well as a multitude of minor tracks and paths that are not on other maps.

Over the course of this year, I have noticed the map grow, with people adding and tweaking things here and there. For example, the routes of the new M80 and M74 appeared as they were constructed, and were changed to live motorways on the day they opened. Six months later, they are still not on Google, Bing, or Yahoo Maps; and thus any of the services that use these.

While the motorway network is a more obvious differentiator — I actually think that the local addition of tracks and paths, for walking and cycling, is the biggest asset of OSM. The likes of the Ordnance Survey, Google, and Navteq will update their maps of the motorways at some point. But they are unlikely to add the minor paths that make up an interesting bike ride, or a great walking shortcut.

As for why I contribute my time to this project, it is an interesting project, that could — in the same way as Wikipedia — become a de-facto standard for maps in a few years time. If everyone (or at least a reasonable number of people) add there own favourite shortcuts and routes, they will all be mapped for everyone to use.

I will post more on the editing I’ve done, the tools I’ve used, and the outputs I’ve seen in further entries. At some indefinite point… probably!

Posted: 29 October 2011, 19:59; tagged: , , , , , .