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.

 

eg_merge_images01_00.png

 

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

eg_merge_images01_01.png

 

We have created a map called Map Layers and have added to it a lower layer from the Google satellite web server and an upper layer from the Google transparent streets layer, which uses transparent pixels in between streets, boundaries and layers.     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.

 

eg_merge_images01_02.png

 

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 alt-clicked the name tabs for the Map Layers window and the Project and Contents 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.

 

eg_merge_images01_03.png

 

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.

 

eg_merge_images01_04.png

 

Choose Images in the filter button menu.

 

eg_merge_images01_05.png

 

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

 

eg_merge_images01_06.png

 

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.

 

eg_merge_images01_07.png

 

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

 

eg_merge_images01_08.png

 

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.   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.  

 

eg_merge_images01_09.png

 

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.

 

eg_merge_images01_10.png

 

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

 

eg_merge_images01_11.png

 

We then choose Use Coordinate System.

 

eg_merge_images01_12.png

 

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.

 

eg_merge_images01_13.png

 

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.

 

eg_merge_images01_14.png

 

We create a new map, called Map, we add a Google satellite layer to it as background.   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.

 

eg_merge_images01_15.png

 

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.

 

eg_merge_images01_16.png

 

With the focus on the Merged SRTM layer, we open the Style panel of the Contents pane and click on the right-hand side of the style properties button.

 

eg_merge_images01_17.png

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.

 

eg_merge_images01_18.png

 

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.

 

eg_merge_images01_19.png

 

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.

 

eg_merge_images01_20.png

 

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

 

eg_merge_images01_21.png

 

We press Update Style.

 

eg_merge_images01_22.png

 

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

 

eg_merge_images01_23.png

 

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.

 

eg_merge_images01_24.png

 

The result is a nicely hill shaded display.   

 

eg_merge_images01_25.png

 

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

 

eg_merge_images01_26.png

 

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

 

 

eg_merge_images01_27.png

 

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

 

eg_merge_images01_28.png

 

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

 

eg_merge_images01_29.png

 

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

Notes

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.

 

eg_merge_images01_30.png

 

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.  

 

Videos

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

Images

 

Maps

 

Projections

 

Coordinate System

 

Contents - Layers

 

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.