Tuesday, 25 February 2014

OS OpenData

I recently came across the Ordnance Surveys OpenData products and decided to look into how I could use some of the data in some of my existing projects.  In particular I have a personal project that I have been developing that uses an A* path finding algorithm with a heuristic that avoids steep inclines and declines, picking the most efficient route through a 3D terrain.

At the current time I have been using a Perlin noise algorithm to randomly generate terrain.  The weakness of this algorithm for generating the terrain is that, without some particular exceptions, it cannot produce certain terrain effects such as cliffs, inlets and sharp changes in terrain.  There are some techniques that can be employed to produce these effects after the Perlin noise has run but again they take some time to get a realistic looking terrain.  Using real terrain would be a great test for the algorithm.


Perlin noise generated terrain
A*algorithm avoiding the water and raised terrain
The OpenData products come in a number of formats and are continually updated to give information from postcodes and boundaries to digital maps.  The product that caught my eye was the OS Terrain 50 which gives height data at 1:50 scale across the whole of the UK. 

OS Terrain 50 is available as:
  • 50 metre grid in ASCII grid and GML 3.2.1
  • 10 metre contours in Esri® shapefile or GML 3.2.1
ASCII grid is a simple file format that specifies height data by storing tile information in a header block then a table of data in the body containing the payload. Geography Markup Language (GML) is an XML grammar to express geographical features. Esri shapefile is a geospatial vector data format for specifying shapes as points, lines and polygons that can be used to represent rivers, water wells and lakes.

My goal is to use one (or possibly all) of these file formats to produce some real terrain data to test my A* algorithm.  To do this I will use my existing test bed application written using WinForms and C# and modify it to read in the OS Terrain 50 data.  The existing test bed is a very simple application that produces a terrain object which is rendered in 2D and is colour coded to show different heights in different colours.  The terrain object is then used by the A* algorithm to calculate the most efficient route through the terrain.

The main tasks are:
  • A GML/ASCII/Shapefile reader will be developed.  There are a number of readers available but I am planning to write my own so that I can learn more about the file format.
  • The application will be redesigned so that a new layer is added that can feed the main application with either a terrain object that was produced by the Perlin noise algorithm or a terrain object built from the OS terrain 50.  In this way the A* algorithm will not be affected by the type of terrain data loaded.
  • The main user interface will be changed to display multiple tiles;
  • The application will be changed to use threads to load the tiles in the background.
  • The colour code will be updated to produce a better quality display.

I am planning to tackle these tasks in hour long sessions over a period of a week and see where I am after the week has finished.  The main risk to completion are finding the time in a week for an hour of coding and half an hour of blogging. 

No comments:

Post a Comment