Saturday, 13 April 2019

NZ Rail Maps: Mosaic overlays and masking

One of the useful things a good graphics package such as Gimp can do is use masks to combine layers when they overlap, so that instead of by default they overlap at their physical edges, you can mask off a part of an image so that the overlap actually is visible at the edge of the mask, which can be any area within the image. When I first started developing the NZ Rail Maps mosaics, I used to mask the historical imagery so that just the rail corridor was visible in the historic imagery and the rest of a mosaic tile showed the current aerial background imagery. There was also a version of each tile created by reversing the order of the historical and current imagery layers, so that the full historical tile was displayed, rather than just a masked off section of it.

There was a second reason I used to mask for, and that was for the historical images, which generally come with a border that is scanned from the contact print, and a copyright notice from Retrolens/LGGA. Since we don't want any of the border displayed on maps, I used to mask out the border, which enabled me to use the entire content area. These days I now crop the images to remove the border, which is useful for 99.9% of the time.

As time has progressed the requirements of the project have been changed so that masking is eliminated for routine mosaic tiles, which are now just the full historical imagery with the layer order never being changed. Hence as existing projects are updated, the layer orders are changed and the masks of this type on the layers are deleted.

Masking is now becoming very useful primarily when overlapping different historical layers and primarily for two purposes:
  • Where two different layers overlap, we can use masking to control where the join between two different layers is positioned. The main reason is where there are features that are a height off the ground, such as buildings, which can be affected by perspective distortion, causing a join across the roof of a building to be discontinuous because one layer may have more distortion than the other. By masking, we can wherever possible move the join to a less conspicuous location (for example on the ground in front of the building) where there is less likely to be visible discontinuity between layers.
  • Where two different parts of one layer are at different heights. An example is where there are railway lines on an embankment of 5 metres or more height going through the middle of a railway yard. Dunedin is an example of this because around 100 years ago the main line was raised up on an embankment in the middle of the railway yard, whereas originally it was on the ground level with the yard tracks. The yard has not been raised, so the issue is that perspective distortion with the embankment can make it difficult to get good alignment of both the embankment and yard tracks. By creating a duplicate of the layer and having the two layers labelled "BANK" and "FLAT respectively we can mask them over each other and then align each part independently of the other. The BANK layer would sit over the FLAT layer in the layer draw order and have just the embankment masked off to appear, the rest of the BANK layer would be transparent to allow the FLAT layer to be shown through.
I actually thought I had dispensed with masking until this week when I have started applying both of the above two situations to get some nice clean alignments and joins in the Dunedin-Mosgiel project.  The result is more masks than ever before, because most of this project had been done without the form of masking I used historically. There were some aerial images already in the project that did not have the border cropped off, which meant some extra work to crop them, requiring them to be rotated to orthogonality within Gimp because the software crop tools only work on orthogonal borders, and then rotated back after cropping. There is one set of two layers in the project that still uses border masking over full uncropped borders in order to maximise the displayed information. But as I noted above most of the time cropping the borders is sufficient.

Anyway I have just about finished masking off and layering everything I possibly can, so at least for the maps for Dunedin to Burnside, the project has now reached 109 layers and around 33 GiB in size and that is where it will be left for now.