Heightmap creation from OS data. (UK Only)

This tutorial will allow you to create heightmap data from Ordnance Survey’s OS Terrain 50 grid data. The information is free to download from https://www.ordnancesurvey.co.uk/opendatadownload/products.html

BenNevis

This process may well work for data from other sources, but as far as I know, this works for 10x10km areas of the UK only and produces a resolution of 50 metres.

Once downloaded and extracted, you will have a great deal of folders listed with two letters to denote the OS grid reference and inside these folders a series of zip files. I found the best method to find out which section of the map you need is to look at http://gridreferencefinder.com/

bideford

In the above example I have searched for my home town of Bideford and the corresponding grid reference comes up as SS 45492 26743. What we need are the first two letters and the first number of both sets of five numbers. In this case SS 4 2, which means I need to look into the folder SS and locate the zip file beginning ss42_OST50GRID_. Extract the file extension with the extension .asc to somewhere you can find it later.

The .asc file contains 205 lines. The first five deal with the number of columns, rows, longitude, latitude and resolution. The only variations from file to file for these five lines are longitude and latitude as there are always 200 columns, 200 rows and the resolution is always 50 metres.

ncols 200
nrows 200
xllcorner 240000
yllcorner 120000
cellsize 50

The next 200 lines deal with 200 points each of height data in metres. Sea level appears to generally be -1.7 and are delimited by spaces.

You’ll need the script I’ve written to run through the points PhotoshopHeightmapV3. I’ve created this and tested under Photoshop CS6 but I see no reason why it won’t work under earlier versions.

Extract the .jsx file. You will need to go to File / Scripts / Browse, locate and open the file. Click process and the script will run through and analyse the data. You will then be presented with two options.Options

If you want to create the Heightmap for a single set of data, you should best use “relative” as this will take the lowest point from that data and set it to true black and the highest point to white. Take note of the range, in my case this was 178.5.

The “absolute” setting will produce a heightmap that is in proportion to the rest of the UK which will go from -1.7m (Sea level) to 1345m. This is advised if you want to create a wider area and tile terrains.

In Photoshop, this process took 30 minutes which does seem like a long time. If anyone wants to take my script and adapt it for another programme or create a standalone .exe, please do and let me know to share it. 30 minutes is a little too long…

This has only created a 200×200 map, so you will need to Image / Image Size and change it to 513×513. Got to File / Save As, and save as a Photoshop RAW file and accept the default options.

When importing into Unity, you’ll need to remember that Unity units appear to be 1 to 1m, so a 10km terrain becomes 10000 x heightrange x 10000. range

I’ve added some water in to recreate the River Torridge and you can see this in the screenshot below. bideford

This entry was posted in Photoshop, UDK, Unity. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current day month ye@r *