Tuesday 31 December 2019

Map Development Levels [3]: Comprehensive Level

Yesterday we posted about the Basic and Intermediate levels of the maps of the NZ Rail Maps project. Today we are going to have an in depth look at the Comprehensive level of the maps.

The main additional level of information added at Comprehensive level is georeferenced historical maps. This requires that the aerial photography sourced from a site such as Retrolens, or Archives New Zealand, is overlaid over existing georeferenced aerial photography, and then tiles are produced that use the same tile grid system as the originals, so that the reference information for the original tile grid system (of the base aerial photography) can be copied to the new tiles.

If you've ever taken a photo on a camera or phone that is tagged with GPS information, you'll understand a little bit about georeferencing. In this instance, a set of source imagery of an area is divided into tiles of a certain size (the ones we use are usually 4800x7200 pixels) and then for each tile, the georeferencing information is added into several additional files (sidecar files) that have the same title as the original image, but with a different file extension. According to the standard format for GIS georeferencing, there is a file that contains the top left coordinates of the tile, the resolution in each axis, and a couple of other coordinates that tell the GIS how much, if any, rotation of the tile is needed. 

The other important information that is present in one of the other files is the Coordinate Reference System that applies to the tile. Maps are drawn according to what is called a "projection", which is essentially a mathematical model for flattening the earth's spherical form into a two dimensional map. In practice, the earth isn't close enough to a real sphere for these projections to be really simple and easy, so there are many different ones, often produced for specific countries. When coordinates are used in GPS, they are specified in degrees and minutes, which are equal to the coordinates from a CRS called EPSG:4326, which also happens to be the main one that is used by Google Earth. In the maps, we choose to use a CRS called EPSG:3857, which uses coordinates specified in metres. This makes it possible for the map scale to show measurements in metres and kilometres. The main reason for using EPSG:3857 is that it is compatible with the KML files that Google Earth produces, which was an early source of information for the maps but is not used now. To sum up, the combination of the Coordinate Reference System and coordinate information provided for each tile tell a GIS how and where to draw a tile onto the map canvas.

Now, rather than invent our own system of coordinates to tell the GIS how to render the historical map tiles, the easiest way to get them into the GIS is to use an existing tile grid. So first of all we download the existing LINZ base aerial imagery for an area, and then lay out the tiles in a graphical editing program (our preferred software is Gimp, which apart from being free and open source software, is eminently suited to handling very large graphics files on a well resourced computer). We then take the historical images, and overlay them on top of the grid of tiles, using coinciding terrain features to line everything up. This is not as easy as it sounds, mainly because Linz orthorectifies its base imagery whereas Retrolens and other historical imagery sources generally don't. 

Orthorectification is a mathematical image processing task that aims to eliminate visual distortion that is inherent in photography, caused by variations in height of terrain and terrain that is out to the sides of a photographic image (i.e. that is being viewed side on). These visual distortions mean that a series of aerial photos taken close together along a visual path, that overlap each other, will each have a different view of target points in the areas that are overlapped. This isn't a problem if the target area is completely flat, but where the target has raised or sunken areas, the three dimensional aspect of these areas is represented differently depending on how far that area is from the lens centre (because of the viewing angle). The concept for orthorectification is to generate an altitude reference model of the target area (for example, by using LiDAR radar data) and then feed that into a program along with the source tiles, the software then corrects the visual distortion (if the altitude model is accurate enough). In practice this process is only as good as the accuracy of the altitude model, and we have seen a number of instances even in the Linz base aerials of bridges appearing to be curved, that are actually straight, due to the incorrect height information being recorded for that area (most likely the height was represented only for the valley not being crossed and not actually for the bridge itself).

When it comes to raw aerial photography like that we can get from Retrolens, the fact it generally isn't georeferenced, or simply that the centreline coordinates for the aerial survey (in other words, the navigational track that the plane taking the photos flew along) is quite likely different, means that alignment of the historical imagery over the base is often difficult especially for raised or sunken terrain (that is, higher or lower than the railway lines we are interested in mapping). It can get really messy where there are a number of rail lines that are at different heights, such as a few places where a rail line goes on an embankment or bridge alongside or over a shunting yard. So at the best of times, the positioning of features according to a historical image can only ever be an approximation.

When we started doing the Comprehensive level mapping, we commenced in the Cromwell Gorge of the Otago Central Railway with the intention of mapping more or less accurately the route of the old branch railway which is now almost all submerged beneath a hydro lake. There have been so many physical changes in that area, not the least because of the lake itself but also the hydro works, that have made it somewhat difficult to obtain accurate rendering of the route, and our first attempt is currently being revised somewhat. This is partly why the Otago Central maps have not been fully released at the moment. The relevant map volume, Volume 12, is the only one that relies on the Comprehensive level mapping for a significant part of its Basic level information, because of the need to use this technique to generate the route in the Cromwell Gorge which is now mostly invisible; on all the other routes, the closed lines are visible enough to draw them directly from other sources. 

Comprehensive level mapping is inherently much slower to produce than the Basic or Comprehensive levels because of the large amount of graphical data needed to generate map tiles at a useful resolution. Typical historical tiles that are at a useful resolution are at a scale of 1:10000 or less. The most common scales found in NZR aerial photography are 1:4300 for station surveys and 1:5500 for corridor surveys. Highway surveys at typical scales of 1:8000 have also proven very useful in a number of cases. These scales at the the sizes generated in Retrolens scans generally require the use of base imagery at a pixel size around 0.1 to 0.2 metres. This naturally results in a need to process very large image sizes to cover a relatively small area on the ground. For example, a tile size of 4800x7200 pixels at 0.1 metres will cover an area of only 480 by 720 metres, with 34 megapixels in the tile. The result is that a powerful computer and a lot of memory and disk space are needed to process the georeferencing of the images and store them as well. These factors combine to ensure that we have decided in the project that Comprehensive level is a lower priority and is mainly confined to the use of the official NZR surveys except in a small number of major sites where other historical generations are useful.

Well that's been a long and very technical post but we felt it was useful to dig into this information about the levels of maps and we hope this creates a greater understanding of what the basis for the type of maps that we produce is, and what sort of output we can expect to see at the various levels in the future.