Spatial Analysis Lab (SAL)

Merge vs. Mosaic for Raster Data

(Note: in ArcGIS 9.1 there is now a 'Merge' Tool for Vector data as well...)

See also Mosaicing Images (as opposed to Grids)

Back to the   GIS Tutorials & Help Page...                         Back to the   SAL Home Page...


Two common methods for combining adjacent or overlapping raster layers are MERGE and MOSAIC. Below are a few notes on the difference between these two tools.


The MOSAIC and MERGE functions work similarly, and both are still available from either command line ArcInfo (GRID) or the Raster Calculator of ArcGIS (Spatial Analyst). However, for geoprocessing from the ArcToolbox, these two functions have now been combined in the single MOSAIC tool.


Neither function will fill gaps between non-adjacent datasets (see Gap notes below).



Raster Calculator (or Command Line ArcInfo)

When the input grids do not have any overlapping area, there is no difference in the output from either MERGE or MOSAIC. The difference is only in the processing of overlapping areas. In the case of MERGE, the sequence of input grids determines the values assigned to cells, giving priority to those entered first. For MOSAIC, overlapping areas were blended to make a smooth transition and the sequence of entry is irrelevant (if on each overlapping area no more than two grids intersect). MOSAIC is typically used for continuous data (such as the spatially adjacent grids representing Digital Elevation Models, satellite images acquired in a slightly different time, containment plumes, etc.)





(Tools / Data Management / Raster / Mosaic or Tools / Data Management / Raster / Mosaic to New Raster)

The MOSAIC tool combines the geoprocessing of both MERGE and MOSAIC. Overlapping areas can be handled in any one of the following manners:

  • FIRST—The output cell value of the overlapping areas will be the value from the first raster in the list. This is the default, and is analogous to the Raster Calculator MERGE).
  • LAST—The output cell value of the overlapping areas will be the value from the last raster in the list.
  • BLEND—The output cell value of the overlapping areas will be a blend of values of the overlapped cells. This blend value on a weight-based algorithm is dependent on the distance from the pixel to the edge within the overlapping area. This is
  • MEAN—The output cell value of the overlapping areas will be the mean value of the overlapped cells.
  • MINIMUM—The output cell value of the overlapping areas will be the minimum value of the overlapped cells.
  • MAXIMUM—The output cell value of the overlapping areas will be the maximum value of the overlapped cells.


MOSAIC requires an existing Grid as its output. However, MOSAIC TO NEW RASTER is identical to MOSAIC, but outputs to a new Grid.





Small gaps between non-overlapping and/or non-adjacent datasets become NODATA (The MERGE or MOSAIC function will not interpolate to fill missing data between adjacent rasters). The following Map Algebra expression may help to solve the problem by interpolating values of the missing cells. First use MERGE or MOSAIC to combine raster datasets (creating a raster with a gap in it). Then use the following expression from the Raster Calculator to fill gaps of up to three rows or columns of NoData cells with the mean cell value of the 4-x-4 square (leaving the valid existing data unchanged). If the gap is wider than three cells, the size of the focal window may be increased. Using the Raster Calculator, enter the following expression (where 'gap_merge' is the name of your mosaiced grid with gaps in it):

            <new_grid> = con(isnull(gap_merge), focalmean(gap_merge, rectangle,4,4), gap_merge)


This is a simple conditional statement where if a cell has no data (is null, i.e., a gap) then a value is generated from the average of the values in a 4x4 cell window around the no data cell. Cells that are not null (i.e., have data) remain unchanged.


If the gap needs to be eliminated from a mosaic made up of categorical rasters (where an average or mean value would not be appropriate), the following approach may be useful:
<new_grid> = eucallocation(gap_merge)

This function assigns the value of the nearest cell (containing data) to the cells in the gaps without any averaging of values (a Euclidean distance allocation).

HILLSHADE NOTE: (Do not MOSAIC hillshades: MOSAIC the DEM's first and then create a hillshade).

When working with multiple DEM files, it is important to MOSAIC the individual DEM files before creating a hillshade. A hillshade process cannot create any 'shading' at the edges of the dataset (there is nothing to compare the edge cells with). This will create data gaps if two hillshades are MOSAICed - even if the original DEM files did not have a gap...


MOSAICING IMAGES (as opposed to Grids)

The standard MERGE and MOSAIC tools in ArcGIS do not work to mosaic image file formats (e.g., adjacent .tif, .jpg or .img files such as air photos, satellite images or scanned maps). To MOSAIC an image file in ArcGIS you must first convert the image file to a GRID (or more typically, to a GRID STACK, which is a combination of Red, Green and Blue GRIDS for the different color bands that make up a multi-band image).


Alternatively, in AH-16, we have the Image Analysis extension available on the Dell computers. This extension does handle the mosaicing of image files (as well as the subsetting or clipping of images, etc.).

The MOSAIC tool in Image Analysis also included Color Balancing and cropping options. Refer to the Image Analysis Help (available from the main drop down list of the Image Analysis toolbar) for more details.



Back to the   GIS Tutorials & Help Page...                         Back to the   SAL Home Page...

ISIA | HML | SAL | Website (stefan) | Lab Manager (Dave Knutson)