Example: Merge Images

In this topic we use the Merge Images command to merge dozens of images showing SRTM terrain elevation data into one image, with various tricks for faster workflow as an experienced Manifold user would do the job.  After creating the new image we style it with a palette and use hill shading to better show terrain elevation.   For a video version of this topic, see the Manifold 9 - Merge Images video.



We have used the painfully inefficient earthexplorer.usgs.gov web site to download 32 SRTM terrain elevation data sets that cover part of the Alps in the North of Italy and touching adjacent countries such as France, Switzerland and Austria.  USGS provides SRTM data in very small data sets which usually have to be merged together for convenient use.   We will import the SRTM data and then merge the separate data sets into one image.

Import SRTM Files

To fit into this documentation, illustrations show a small Manifold desktop, with only a few panes, docked to the right side.  In real life we use a much larger Manifold desktop, and more panes would be turned on, with panes docked to the left or to the right, or undocked, as we prefer.   Right-click a pane's tab to change where it is docked.  Manifold will remember that new arrangement for our next session.





We have created a map called Map Layers using a Google satellite web server base layer from the Google satellite web server.  We have also added the Google transparent streets image server as a second layer.  That layer has transparent pixels in between streets, boundaries and layers, which allows the lower satellite image layer to show through in between labels.    The map window uses Pseudo-Mercator projection, the same as the Google layers, so those Google layers will not be re-projected on the fly into a different system and thus distort the labels the are rendering.  


We have also created a folder called SRTM3 into which we will import the SRTM data.   We click on the SRTM3 folder to highlight it and then we choose File - Import.



In the Import dialog we navigate to the folder into which we have downloaded the data sets, all in .tif format.  We highlight all the files and press Import to import them all at once.

Add Images to Map

In what follows we have Shift-clicked the name tabs for the Map Layers window and the Project and other panes to undock the map window and the panes.   This allows us to make the illustrations of each slightly larger to fit into this documentation.



When we clicked Open the SRTM files were imported into the SRTM3 folder with three components for each file: an image, the table used by the image and a metadata comments file.  To make it easy to add all the images as layers to the map with one motion, we will use a simple trick.   We press on the filter button in the project pane and choose to show only images.



Choose Images in the filter button menu.



Now the Project pane shows only images.   We can click on the first of the SRTM images to highlight it.



We then scroll to the bottom of the Project and Shift-click on the last of the SRTM images to highlight that image and all of the images in between.



We can now drag and drop the highlighted block of images into the map with a single mouse move.



That adds all of the images at once to the map as layers.   This is much faster than dragging and dropping thirty two images one at a time into the map.  


Seen together in the map the image layers fit together neatly to form a rectangle.   We have not styled any of the terrain elevation data sets so they use default formatting using a grayscale based on the terrain elevation numbers for each pixel, with an initial effect of overall gray.  It would be tedious to apply the same style to each of 32 layers, so instead we will merge all the images together into a single image and then we can style that image just once.

Merge Images

We now launch Edit - Merge - Merge Images.  



For a Name, we enter Merged SRTM.   The dialog has automatically turned off the Google layers, both the uppermost layer visible in the illustration above and also the very lowest layer, scrolled out of sight.  The Merge dialog knows that most likely we do not want to attempt a merge with layers that are petabytes in size.  


The Coord system is wrong for our purposes because it is based on the coordinate system used by the map, Pseudo-Mercator as used by huge Google layers, and it has the wrong Local scale X and Local scale Y values for pixels in the SRTM data.   We will change that.



The easiest way to specify a sensible coordinate system is to right-click onto any of the images which will participate in the merge.  



We then choose Use Coordinate System.



The coordinate system used by the SRTM images, EPSG:4326 Latitude / Longitude system with local scale values for pixels that are good for the SRTM data, is automatically loaded into the Coord system, to will be used by the new image we will create.   We press Merge Components.



With amazing speed, only a few seconds, Manifold creates the new image, called Merged SRTM, as well as a new table, Merged SRTM Table, which stores tiles for the image.   The 32 images that were used to create this new image have not been altered in any way.   They are still in the SRTM3 folder and still participate as layers in our Map Layers map.    A copy of the data from each of those images has been used to create the new Merged SRTM image.



We create a new map, called Map, using a Google satellite layer to it as background, base layer.   The map appears zoomed out to the full extent of the world as shown by the Google satellite web server layer.    We drag and drop the Merged SRTM image into the map.   To zoom to fit to that image, we Ctrl-click the Merged SRTM layer.



Seen above is the Merged SRTM layer in the map.  We've zoomed out slightly to provide surrounding context from the background Google satellite layer.  

Style the New Image

It is now time to Style the new image to provide a better display of the terrain elevation data it contains.



With the focus on the Merged SRTM layer, we open the Style pane.



Single channel images, that is, elevation data, by default will be shown with all RGB output channels powered by the same channel, creating an RGB grayscale image.   We will change that to using a single channel to drive a palette.  We click on the channel picker control and choose Channel 0.



We choose Channel 0 as the single channel (the only choice), we specify 8 for the number of Breaks, we use equal intervals as the method,  we press Tally and then to color the resulting intervals we press the Palette button to choose a palette.



We use the Color Brewer CB Spectral palette.   It automatically colors the intervals.   However, we would like to reverse colors so lower heights are blue and greater heights are red.   To do that, we click onto any of the intervals to move the focus into the intervals list.


We then press Ctrl-A to select all of the intervals.



We can then right-click onto any of the color wells and choose Reverse.   That reverses the order of colors used.



We press Update Style.



That colors the terrain elevation data to bring out more features.  We can do an even better job by applying hill shading.



We click on the Options tab, check the Use shading box, and enter a Z scale of 0.08, which we know from experience gives a nice effect with SRTM data.   We press Update Options.



The result is a nicely hill shaded display.   



We drag and drop the Google transparent streets layer into the map, above the Merged SRTM layer.   That adds labels.



As we pan and zoom into the map the Google transparent layer will automatically add more detail.



Zooming in, we can see the SRTM data provides much useful terrain elevation detail in the region.



Turning off the upper Google layer we can see the clarity and convenience of merging together many tiles into a single, seamless image.



Zooming far into the region of Lake Como we can see the first rate detail and rendering.   Not bad for free data!


No taxes - Panning and zooming within our map we can see many interesting locations, not the least of which is the very Southern part of Switzerland that extends down past the alps into the lake country of Italy.  It is a part of Switzerland where palm trees and lemon trees grow.



In the display above, the region in the center of the view surrounding the Casino Campione d'Italia we see the region called Campione, a part of Italy that is a geographic island surrounded by Switzerland.  Electricity, postal and other services are provided by Switzerland, but Campione is nonetheless a part of Italy, although the few residents of Campione are taxed neither by Switzerland (it is a part of Italy), nor by Italy (it is administered by Switzerland).   They therefore pay few or no taxes at all, with the costs of running Campione primarily financed by the Casino.   As with all good things this may come to end, given rising financial pressures.  



Manifold 9 - Merge Images  - Manifold makes it easy to combine rasters like images and terrain elevation data from many different files or layers into a single layer or data set.  The new Merge dialog will automatically deal with overlaps, different coordinate systems and similar real world complications.  This video shows how to merge step by step, and then colors the result with a palette and applies hill shading.


See Also







Coordinate System


Layers Pane


Edit - Merge - Merge Drawings


Edit - Merge - Merge Images


Style: Channels and Outputs Tutorial


SQL Example: Kriging - We use SQL functions to create a raster terrain elevation image from vector contour lines in a drawing, using SQL functions for Kriging interpolation.


Example: Resize an Image using Merge - We can change the size of an image while maintaining georegistration by using the Merge Images command.  This example shows how to take an image that is 3,038 x 4,334 pixels in size, using approximately 36 meter pixels, and to create a re-sampled image that is 1,115 x 1,590 pixels in size, using 100 meter pixels.