This topic covers the Merge Images dialog used to combine multiple images into a single image.
The Merge dialog works when a map window has the focus. The dialog is used to merge layers within the map into a new layer. The old layers are not deleted or altered: they are used as the sources for data that is merged to create a new layer of the specified name.
We can merge images that have been imported into the project, or images that have been linked into the project, or a mix of imported and linked images, to create a new, merged image.
The Edit - Merge - Merge Images command is enabled when the focus is on a map window that contains image layers. It creates a single, new image by combining image layers that appear in a map. The original image layers are not changed in any way. The Merge Images command can also be used to resize an image, as shown in the Example: Resize an Image using Merge topic.
With the focus on a map window, launch the command by choosing Edit - Merge - Merge Images. See the Example: Merge Images topic for a detailed, step-by-step example. See the Manifold 9 - Merge Images video for a video version of the example.
Images to be merged can:
The dialog will automatically upscale images to match the maximum number of channels.
We can also merge images in a map that includes layers in addition to the images being merged. For example, a map may contain image layers that are web server image layers that appear above or below the image layers that are to be merged.
Create a map.
Drag and drop the images to be merged into the map.
If any of the images overlap, order the layers so the preferred images are on top.
Choose Edit - Merge - Merge Images.
Enter a Name for the new image if the default name "Image" is not desired.
Double-click the on/off box to turn off any image that is not to be merged.
Right-click onto one of the images that is to be merged, and choose Use Coordinate System.
Press Merge Components. A new image and tile table will be created in the project that combines all the merged images into one image.
In the very simple case where a map contains as layers only those images that are to be merged, the default coordinate system will automatically be set to that used by one of the merged images. If all of the images use the same coordinate system, that is a good choice. In that simple case, we do not need to do step 7 above.
If different images to be merged use different coordinate systems, it is good to get into the habit of right-clicking an image to be merged and choosing Use Coordinate System. That way, we specify what coordinate system is desired, in case some of the images to be used have very different coordinate systems.
Set the coordinate system to be used for the result by right-clicking one of the images to be merged and choosing Use Coordinate System.
The result is a more sensible size for the resulting image.
The Merge dialog uses the same Manifold grid controls used in the Layers pane and in many other list dialogs. Layer order may be important in case of overlaps. When one layer overlaps another layer, the upper pixels will be used for the merge.
Choose a name for the new image created by merging together image layers.
The coordinate system to use for the new, merged image. By default, the coordinate system used by the map. We can change this to whatever system is desired by:
The easiest way to specify a sensible coordinate system for the new, merged image is to use the coordinate system of one of the images to be merged. We can do that by right-clicking into the row for one of the images to be merged and choosing Use Coordinate System.
Coordinate system picker. Choose the Edit Coordinate System in the menu to manually specify the coordinate system for the new, merged image. We can manually specify all coordinate system parameters, including Local scale X and Local scale Y if required. Unless we know what such parameters mean, it is wiser to simply choose a coordinate system based on one of the images to be merged.
Size of pixels to be created (Local scale X and Y values). One value if both X and Y local scales are the same, otherwise two values will be shown. The size of pixels to be created is one of the specifications for the coordinate system, in the Metrics button of the Coordinate System dialog. We can alter the size of pixels by altering the metrics specified in the coordinate system. See the Example: Resize an Image using Merge topic for a step by step example.
14,401 x 3,601
Size of the image to be created in pixels.
Right-click onto an image layer row and choose Use Coordinate System, to use the coordinate system of that image for the resulting merged image.
Ctrl-click onto an image layer row to select that image layer.
Move each selected image layer up in the list.
Move each selected image layer down in the list.
Move to Top
Move all selected image layers to the top of the list, retaining their relative orders in a group at the top of the stack.
Move to Bottom
Move all selected image layers to the bottom of the list,, retaining their relative orders in a group at the bottom of the stack.
(list of images)
The Merge dialog provides a list of images to be merged, in the vertical order in which they appear as layers in the map window that had the focus when the Merge command was launched. We can override the vertical order of images by using the Move commands to move image layers up and down.
When images overlap, pixels from the uppermost image in the overlapping region will be used in the merged result. This allows us to compose layers in the order in which the resulting overlaps look best in the map, for smoother visual appearance if contrast or other visual factors vary from image to image. This also allows us to place a slightly lower resolution image that is more trusted above an image that might be slightly higher resolution but is considered less reliable, so that the more trusted image is used in the merge.
Coordinate system icon indicating how that layer will be re-projected to match the Coord system selected for the new component. A red icon means that the coordinate system of a component is incomplete and will be treated as the default pseudo-Mercator. A black icon indicates that component data will be re-projected and that the re-projection will be curvilinear and lossy. A gray icon indicates that component data will be shifted, scaled or have axes swapped, resulting in a high accuracy transformation. No icon for vector data means that component data will not be transformed in any way. No icon for raster data means that component data might be at most shifted with the original pixel values kept intact.
Layer off (empty box) or on (filled box). Double-click a layer name or the on/off box to toggle the layer off and on. Applies
to all selected layers. Layers that are off will not be used in the merge.
The Merge dialog shows a list of all image layers in the map, allowing us to choose which will be merged. Similar to how the Layers pane allows us to turn layers on and off, double-clicking on the box at right allows us to include or not include a layer. The dialog automatically un-checks layers for big images on web data sources like Bing or Google.
In the illustration above we have already right-clicked one of the images to be merged and have chosen Use Coordinate System, to choose the coordinate system for the coordinate system that will be used by the new, merged image.
Very Important: The coordinate system used for the new image by default will be the same as the coordinate system used by the map. If the map uses the same coordinate system as one of the images to be merged, we can accept the coordinate system offered by default as a reasonable choice. If the map does not use the same coordinate system as one of the images to be merged, it is probably a mistake to use the coordinate system of the map. Instead, we should right-click onto one of the images to be merged and choose Use Coordinate System. That will specify a reasonable coordinate system to use.
For example, when we create a map based on a web server layer like Google or Bing, that map will be created with the same Pseudo-Mercator coordinate system used by that web server image, including all local scale values that make sense for that web server. However, such values almost never make sense for other imagery.
The illustration above shows what the dialog looks like right after we choose Edit - Merge - Merge Images, and before we right-click one of the image layers and choose Use Coordinate System. By default, the map uses the same Pseudo-Mercator system as Google, setting pixel size to about 7.5 cm per pixel, resulting in an image that is almost 12 million pixels wide, over 410 terabytes in size, a clear mistake that results from using the wrong local scale for pixel size (see Notes below).
It is critically important that we specify the coordinate system sensibly including the Local scale X and Local scale Y values used for the image. Maps will often be created based on web server layers like Google or Bing, and thus will use the same Pseudo-Mercator coordinate system they use. However, simply accepting Pseudo-Mercator as used by Google or some other web server is probably not correct. The Local scale X and Local scale Y values set the pixel size for image. Accepting whatever is used for a web server layer, or simply changing the coordinate system without adjusting the Local scale X and Local scale Y values to what they should be for the images in use, can result in wildly inappropriate values for the images we are merging. That can cause the merged image to be hundreds of terabytes in size or otherwise unusable.
Avoid such problems by right-clicking into one of the images to be merged and choosing Use Coordinate System. That will specify for the new image exactly the same coordinate system already in use by the images that are being merged, almost always a safe choice.
Consider the map above, which has a Google satellite web server layer as the bottom layer, with four SRTM3 terrain elevation image layers above it. The uppermost layer is a Google streets web server layer where the pixels between streets are served by the Google web server as transparent pixels.
The "transparent" Google streets layer is a great layer to use to show streets and location labels above our terrain elevation data, to provide context for what is seen in the terrain elevation data. The map window uses Pseudo-Mercator projection, to allow display of labels as rendered by Google without distorting those labels by re-projecting them on the fly into a different projection.
To combine the four images into a single image we choose Edit - Merge - Merge Images.
However, when we launch Merge Images we see that the Coord system is taken from the map, which uses the same Pseudo-Mercator coordinate system as used by the Google layers. The dialog indicates a really huge image will result, since the Pseudo-Mercator projection that uses scaling appropriate for Google is a bad choice for SRTM data.
We can, if we like, create the new, merged Image using the Pseudo-Mercator system, but to do that we cannot just use the Pseudo-Mercator system with settings as used by Google because the Local scale X and Local scale Y values will be wrong. We would have to adjust those local scale values in the Metrics dialog, to avoid creating a merged image that is many terabytes in size.
To save ourselves from having to think about what the right values would be to use, we simply right-click onto one of the images to be merged and we choose Use Coordinate System.
This will replace the Pseudo-Mercator coordinate system with the same coordinate system used by the images to be merged.
Choosing Use Coordinate System tells the Merge dialog to use that coordinate system for the new Image that is to be created. Since the images we are merging together already have Local scale X and Local scale Y values set to something that makes sense (or else they would not have appeared OK in the map), when we use the coordinate system from one of those images we automatically set the Local scale X and Local scale Y values for the new image that is created also to something sensible.
In this case, we see it is the EPSG:4326 Latitude / Longitude coordinate system that SRTM data uses, with local scales set to 0.00028 degrees and a total image size that is no larger than the sum of sizes of the four images that are being merged together.
The dialog has automatically un-checked the Google layers, knowing they are super-huge web server layers that are not likely layers we want to merge. We can now press Merge Components to create a combined image.
The new Image will be created using EPSG:4326 Latitude / Longitude coordinate system with sensible settings.
Consider a variation of the example above, where some of the images to be merged use different coordinate systems, data types, or number of channels.
In the illustration above, two SRTM tiles use the default WGS 84 (EPSG:2857) coordinate system with pixels using int16 data type.
Two of the SRTM tiles have been modified so they use different coordinate systems (with different pixel sizes), different data types for their channels, and different channel types. The 008 float64 image is in a custom Orthographic projection and uses float64 as the data type for values in pixels. The 009 RGB image uses Pseudo-Mercator projection and has three channels, using int16x3, as might be typical for an RGB image. Both the 008 float64 image and the 009 RGB image within their coordinate systems have local scales set to approximately the same sized pixels as resulting in the default WGS 84 (EPSG:2857) coordinate system.
The map window uses default Pseudo-Mercator projection, taken from the Google satellite web server base layer. The local scale used by Google results in very small pixels, since the maximum resolution Google can provide in some areas is better than ten centimeters.
Launching the Edit - Merge - Merge Images dialog, we see that the initial coordinate system taken from the Google satellite web server base layer results in pixels that are 7.5 centimeters by 7.5 centimeters, resulting in a very large image to cover that much of Italy in such high resolution. None of the images we are merging are anywhere near that high resolution, so we will use the coordinate system of one of the images for the resulting image.
We will right-click the 009 RGB image and then choose Use Coordinate System to use the Pseudo-Mercator coordinate system, complete with the local scales used.
The result is that the merged image will have pixels that are 31 meters wide by 44 meters high, and will be 14,494 by 3,705 meters in size.
The dialog also reports that three of the other images will be re-projected to match the coordinate system of the 009 RGB image.
Press Merge Components to create a new, merged image, using the Name we have provided: Mixed Merge Image.
We can drag and drop the resulting Mixed Merge Image into the map to see what it looks like, turning off the other layers.
The image will be styled by default as an RGB image using the channel data that now exists in the image. Why are the regions that came in from tiles other than 009 RGB colored in shades of blue?
To understand, we begin by looking at the Info pane:
When combining images using different data types and different numbers of channels into a single image, Manifold creates that single image using the maximum number of channels of any of the images to be merged, and using the most detailed data type of any of the images to be merge.
The most detailed data type was the float64 data type used by the 008 float64 image, so the channels used in the Mixed Merge Image use float64 data type in each channel. The greatest number of channels was the three channels used in the 009 RGB image, so the Mixed Merge Image also has three channels, resulting in a float64x3 data type for each pixel. That provides a detailed enough data type with enough channels so that no data from any of the images being merged will get lost.
The pixels in the region covered by the original 009 RGB appear in grayscale coloring, because that tile had three channels, with the same elevation value in all three channels. When those values were copied over into corresponding pixels in the merged result, those pixels also have three channels with elevation values that result in a grayscale look.
The other three tiles, however, had only one channel in each pixel, channel 0. When those values were copied into corresponding pixels in the merged result, the channel 0 values were copied into channel 0, but the other two channels have zero values in them for each pixel, since the source tile had only one channel's worth of data.
We can take a look at pixel values by zooming in to a region North of Verona, and then alt-clicking to pick a tile where there is plenty of blue color. We then click a spot within that tile to pick that pixel.
The Info pane reports the value of the pixel at that location. We can see that the pixel has a value of [1086, 0, 0], giving the values in channel 0, channel 1, and channel 2 in the float64x3 data in the pixel. The 1086 number was merged in from the interpolation of pixels in the n45_e011_1arc_v3 tile at that position. It is a round number because the n45_e011_1arc_v3 tile used int16 data type, so the float64 number is also precisely 1086 and thus shown without many trailing zeros to the right of the decimal point.
Why the blue color? Pixels internally are stored as blue, green, and red channels, with channel 0 corresponding to blue color values in an "RGB" image, channel 1 corresponding to green, and channel 2 corresponding to red. Pixels that have non-zero numbers in channel 0 but with zero in channels 1 and 2 will be rendered in shades of blue. If we like we can use a self-join in the Join dialog to copy the values from channel 0 into channel 1 and channel 2, to create a grayscale equivalent, as with the pixels that came in from the 009 RGB merged image.
We can merge images that have been imported into the project, or images that have been linked into the project, or a mix of imported and linked images, to create a new, merged image.
We start with a project that has ten raster images that are linked from GeoTIFF files providing SRTM terrain elevation data. The data for the images remains in the original files: it has not been imported into storage within the project.
The illustration above shows the ten images as layers in a map, with a Bing streets image server as a background layer. The images show SRTM terrain elevation data sets, for a series of adjacent rectangular regions, 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 relatively small data sets, which usually have to be merged together for convenient use. We will merge the separate data sets into one image.
The images appear with default formatting, which ends up being fairly low contrast within each tile. The Bing layer is shown with 50% opacity (set in the Layers pane), to provide a less visually intrusive background.
The illustration at left above shows the project pane with the ten data sources that were created when we linked the GeoTIFF files into the project. All of the images uses the same coordinate system, which in this case is cited as WGS 84 (EPSG:4326). That is the Latitude / Longitude coordinate system by another name.
For example, in the illustrations above the active layer in the map is the layer for the n47_e011_1arc_v3 SRTM data set. We show the data source for that layer open, to show the image within the data source that we have dragged and dropped into the map. Note that the Info pane shows the coordinate system for that layer as WGS 84 (EPSG:4326).
All ten of the images could have used different coordinate systems, and they all still will have appeared correctly in the map, and they all could be merged together, even if they used different resolutions.
To merge the ten linked rasters into a single raster image within the project, with the focus on the open map window we choose Edit - Merge - Merge Images.
We enter a useful name for the resulting, merged image. The coordinate system assigned by default to the new image is the same as the map window, in this case the default Pseudo-Mercator projection. From the prediction just below the coordinate system we can see that the default image that will be created for that coordinate system using 1 meter resolution will be 556630 x 326552, a very large image. That's much larger than makes sense given the number of pixels in each of the images to be merged, so we will specify a different coordinate system.
To specify the coordinate system of the resulting image, we have three choices:
For this example, we use the second option, using a coordinate system from one of the images to be merged.
The readout for the new image now provides the size of pixels in degrees, since the coordinate system uses degrees as a unit of measure, with the image being 18001 x 7201 pixels. That is better. We press Merge Components to do the merge.
A new image, called Alps, and the image's table appear in the Project pane. Manifold has automatically imported the data from the ten linked GeoTIFFs, and then merged that imported data into a new image that is now stored within the project.
We drag and drop the new Alps image into the map. It appears in default style with better contrast, since the default styling has a larger range of terrain elevation values to work with.
We can Style the new Alps image using the Classic - Altitude palette, with the shading option set to a Z scale of 0.05.
Manifold is very fast, so fast that usually we will not encounter delays when merging images. However, if we want to merge many, large layers, such as 200 SRTM terrain elevation images, the time to render each layer that is added to a map can add up. It can also take time to import many layers into the project.
The following tips can make it easier to work with many large layers:
See the example in the Edit - Merge - Merge Drawings topic for a step by step example of working with many big layers when merging. The same techniques apply to merging many images.
Different Coordinate Systems - The Merge dialog will automatically handle different coordinate systems used by the images being merged.
Different Numbers of Channels - The Merge dialog can merge images even when they have different numbers of channels. The resulting image will have the largest number of channels found in any of the images being merged. For example, if we have an RGBA image that uses four channels that is merged with an image that only uses one channel the resulting merged image will have four channels. This rule allows us the convenience of merging images with different numbers of channels, but as a practical matter it means that palette images which depend upon using a single channel as an index into a palette will lose their coloring.
Using Pseudo-Mercator with Corrected Scale Values - As mentioned above, we could use the Metrics dialog to manually set Local scale X and Local scale Y values to something appropriate for the image data we are merging. To do that, we click on the coordinate system picker button for Coord system and we drill down to setting a custom coordinate system, drilling down to the Coordinate System Metrics dialog.
The Pseudo-Mercator coordinate system as used by Google uses a local scale of X and Y just slightly above 0.07 meter per pixel in X and Y directions.
We change that to using 40 meters per pixel in X and Y directions. We also set 0 for the local offsets and then press OK back up through the dialogs to the Merge dialog.
The resulting custom system, which we have named custom pseudo merc, is a Pseudo-Mercator system like that Google uses but with local scaling and offsets that are a better match to the SRTM data we use. As we can see, using pixels that are 40 meters square results in created image size about that which would be created by using the coordinate system of one of the merged images.
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.
Edit - Merge - Merge Drawings
Example: Merge Images - A step-by-step example using the Merge Images command showing how 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.
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.