DATAMERGE

Merge and recombine multiple bands into a single file


EnvironmentsPYTHON :: EASI
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Examples :: Related

Back to top

Description


DATAMERGE merges and recombines multiple bands from several files into a singe file by using the georeferencing of the source files.
Back to top

Parameters


datamerge(mfile, dbic, filo, ftype, foptions, extent, nodatval, resample)

Name Type Caption Length Value range
MFILE * str Input file name, folder, or text file 1 -   See parameter description
DBIC List[int] Input raster channel or channels 0 - 1024  
FILO * str Output merged file name 1 -    
FTYPE str Output file type 0 - 4 Default: PIX
FOPTIONS str Output file options 0 -    
EXTENT str Output file extent 0 - 12 UNION|INTERSECTION
Default: UNION
NODATVAL List[float] NoData value of output file 0 - 1  
RESAMPLE str Resampling method 0 - 5 See parameter description
Default: NEAR

* Required parameter
Back to top

Parameter descriptions

MFILE

The name of a file, or a folder or text file that contains the data to process. If necessary, you can use a wildcard (*) in the string.

You can specify the value of the MFILE parameter by using any of the following:
If you specify a text file, the following general rules apply:
The column structure of a text file you specify for DATAMERGE must be:
MFILE;DBIC

If the combination of parameters is invalid for an input file, a warning message displays, and no processing occurs. However, if the output file or its associated directory already exists, the processing is aborted.

DBIC

The channel or channels in the input file to process. If no value is specified for this parameter, DATAMERGE processes all channels in the source file.

This parameter may be overridden by an entry in a text file when one is specified for the MFILE parameter.

FILO

The name of the output file to which to write the merged bands.

A file with the same name must not exist in the folder; otherwise, processing stops, and an error message is displayed.

FTYPE

The format of the output file. The format must be a GDB-recognized type.

Supported formats include, among others:

For a complete list of GDB-recognized file types, see GDB-supported file formats.

FOPTIONS

The file-creation options to apply on creating the output file. These are specific to the format of the file. In each case, the default of no options is allowed. You can specify the compression schemes, file-format subtypes, and other information.

Different options are available for each type, as described for the FTYPE parameter.

For a complete list of GDB-recognized file types, see GDB-supported file formats.

This parameter is optional.

EXTENT

The definition of the extents of the output file.

There are two options:
  1. UNION: The extents of the output file are large enough to include all of the extents of the input file. No cropping of data occurs.
  2. INTERSECTION: The extents of the output file are based on the region of overlap for all input files. Some cropping of data may occur.

NODATVAL

The pixel value to use as the NoData value in the output file.

All output pixels that do not have a value assigned by the merge process will be assigned a NoData value.

The NoData value must fall within the range of the output raster data type.

If no value is specified for this parameter, the NO_DATA_VALUE from the file or channel metadata is used, if it exists.

This parameter is optional.

The following table provides some use scenarios of how DATAMERGE processes the NODATVAL parameter.

When the value of NODATVAL is And an input channel Then
Specified Has a NO_DATA_VALUE in either file or channel metadata
  • The value of the NODATVAL parameter, set at the file level, is used as the output NO_DATA_VALUE
  • Pixels in the input channel that have the input NO_DATA_VALUE need to be changed to the new value from the NODATVAL parameter
  • Pixels that are outside of the original image bounds in the output image should have their value set to the value of the NODATVAL parameter
  • Pixels in the input image that have the same value as that of the NODATVAL parameter should have their value increased by 1 (or decreased by 1 if the value is at the high extent of the data range)
  Does not have a NO_DATA_VALUE in either file or channel metadata
  • The value of the NODATVAL parameter, set at the file level, is used as the output NO_DATA_VALUE
  • Pixels that are outside of the original image bounds in the output image should have their value set to the value of the NODATVAL parameter
  • Pixels in the input image that have the same value as that of the NODATVAL parameter should have their value increased by 1 (or decreased by 1 if the value is at the high extent of the data range)
  Has a NO_DATA_VALUE in both the file and channel metadata
  • The value of the NODATVAL parameter, set at the file level, is used as the output NO_DATA_VALUE
  • Pixels in the input channel that have the input channel level NO_DATA_VALUE need to be changed to the new value of the NODATVAL parameter
  • Pixels that are outside of the original image bounds in the output image should have their value set to the value of the NODATVAL parameter
  • Pixels in the input image that have the same value as the NODATVAL parameter should have their value increased by 1 (or decreased by 1 if the value is at the high extent of the data range)
Not specified Has a NO_DATA_VALUE in either the file or channel metadata
  • The input NO_DATA_VALUE, set at the channel level, is used as the output NO_DATA_VALUE
  • No pixel value needs to be changed, they can be copied as is
  • Pixels that are outside of the original image bounds in the output image should have their value set to the NO_DATA_VALUE
  Does not have a NO_DATA_VALUE in either the file or channel metadata
  • Do not set any NO_DATA_VALUE metadata
  • No pixel values need to be changed, they can be copied as is
  • Pixels that are outside of the original image bounds in the output image should have their value set to the lowest possible value in the data types range
  Has a NO_DATA_VALUE in both the file and channel metadata
  • The input channel level NO_DATA_VALUE, set at the channel level, is used as the output NO_DATA_VALUE
  • No pixel value needs to be changed, they can be copied as is
  • Pixels that are outside of the original image bounds in the output image should have their value set to the NO_DATA_VALUE

RESAMPLE

The resampling method to use to determine the output pixel values.

Supported values are:
Back to top

Details

You can use DATAMERGE to merge image channels from separate files with georeferencing information into a single output file. Only the selected channels from the input files in the output file are moved.

DATAMERGE uses the projection information and pixel size from the first file in the list to set the projection and pixel size in the output file. If you want to use the projection and pixel size from a specific file, you can do so by specifying it in an input MFILE. The file containing the project and pixel size must be the first in the list; alternatively, you can rename the input files so that file is the first one in the folder.

The order in which files are entered per the MFILE parameter determines the order of the channels in the output file. For example, the first file is the first channel, the second file is the second channel, and so on.

Back to top

Examples

Merge image band files in DataMerge.txt into one PCIDSK file, called Merged.pix, the extents of which will be a union (UNION specified for EXTENT) of the extents of all of the input files.

DataMerge.txt contains four lines of band file names:

"C:\DEMO\po_123456_red.pix"
"C:\DEMO\po_123456_grn.pix"
"C:\DEMO\po_123456_blu.pix"
"C:\DEMO\po_123456_nir.pix"
 
from pci.datamerge import datamerge

mfile = "DataMerge.txt"
dbic  = []
filo  = "Merged.pix"
ftype = ""
foptions = ""
extent = "UNION"
nodatval= []
resample=""

datamerge(mfile, dbic, filo, ftype, foptions, extent,nodatval,resample)

The output file channel listing look like following:
  • C:\Demo\Merged.pix
  • [S 4PIC 512P 512L]Day-Month-Year
  • 1 [16U] ADS red(0.610-0.660 um)[po_123456_red.pix]
  • 2 [16U] ADS green(0.535-0.585 um)[po_123456_grn.pix]
  • 3 [16U] ADS blue(0.430-0.490 um)[po_123456_blue.pix]
  • 4 [16U] ADS nir(0.835-0.885 um)[po_123456_nir.pix]

Merge image band files in DataMerge.txt into one PCIDSK file, called Merged2.pix, the extents of which will be an intersection (INTERSECTION specified for EXTENT) of the extents of all of the input files.

DataMerge.txt contains four lines of band file names:

"C:\DEMO\po_123456_red.pix;1"
"C:\DEMO\po_123456_grn.pix;2"
"C:\DEMO\po_123456_blu.pix;3"
"C:\DEMO\po_123456_nir.pix;1,2,3"
 
from pci.datamerge import*

mfile = "DataMerge.txt"
dbic  = []
filo  = "Merged2.pix"
ftype = ""
foptions = ""
extent = "INTERSECTION"
nodatval=[]
resample=""

datamerge(mfile, dbic, filo, ftype, foptions, extent,nodatval,resample)

The output file channel listing look like following:
  • C:\Demo\Merged2.pix
  • [S 6PIC 512P 512L]Day-Month-Year
  • 1 [16U] ADS red(0.610-0.660 um)[po_123456_red.pix]
  • 2 [16U] ADS green(0.535-0.585 um)[po_123456_grn.pix]
  • 3 [16U] ADS blue(0.430-0.490 um)[po_123456_blue.pix]
  • 4 [16U] ADS nir(0.835-0.885 um)[po_123456_nir.pix]
  • 5 [16U] Filtered ADS nir(0.835-0.885 um)[po_123456_nir.pix]
  • 6 [16U] Resample ADS nir(0.835-0.885 um)[po_123456_nir.pix]

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.