topo-merge v3.2.3¶
Mercurial revision 5786:5c8b45563631 | 2026-08-04
Description¶
topo-merge is a tool designed to merge Digital Terrain Models (MNTs). It combines multiple input bathymetry or topography files into a single output, allowing for flexible customization of the merging process.
Usage¶
topo-merge [OPTIONS] input1 [input2 ...]
Options¶
General Options¶
Option |
Description |
|---|---|
|
Display help and exit. |
Input/Output Options¶
Option |
Description |
|---|---|
|
Path to the base bathymetry or a template string in the format: |
|
Name of the input bathymetry variable to prepend to the standard list of variable names tested. |
|
Path to a file containing a list of input files (overrides command-line input arguments). |
|
Input format (e.g., |
|
Output file name (default: |
|
Output format (e.g., |
|
Replace the base bathymetry with the merged output. |
Spatial Selection Options¶
Option |
Description |
|---|---|
|
Path to a selection polygon file. Data outside this polygon will be ignored. See also |
|
Selection frame in the format: |
|
Libproj4 projection parameters. Only effective if |
Data Processing Options¶
Option |
Description |
|---|---|
|
Toggle depth/altitude for the final topography (invert sign). |
|
Toggle depth/altitude for the imported topography (invert sign). |
|
Minimum depth to import (values below this threshold are ignored). |
|
Maximum depth to import (values above this threshold are ignored). |
|
Path to a file to convert hydrographic levels to mean levels by adding its values. |
|
Path to a file to convert hydrographic levels to mean levels by subtracting its values. |
|
Replace this tagged value in the base bathymetry with input MNT values. |
|
Only import data on masked values in the base bathymetry. |
|
Number of iterations for growing unmasked pixels. |
|
Smoothing options in the format: `”zmin= |
|
Enable special routines for handling polar grids. |
Output Customization Options¶
Option |
Description |
|---|---|
|
Compression level for the output file (0 to 9, default: 0). |
|
Enable debug verbose mode. |
Formats¶
Supported input/output formats:
QUADTREENETCDFGLOBEGRDCOMODOASCIIASCII_GISASCII_SLIMASCII_GETASCII_DTUGEOTIFFGDAL_HANDLED
Note: Most formats are inferred from the file extension, except for
QUADTREE, which must be explicitly specified.
Examples¶
Basic Merge¶
Merge two input files (input1.grd and input2.grd) into a single output file:
topo-merge -o merged_output.grd input1.grd input2.grd
Merge with Base Bathymetry¶
Merge inputs using a base bathymetry file (base.grd):
topo-merge -b "file=base.grd variable=z format=GRD" -o merged_output.grd input1.grd input2.grd
Merge with Variable Name¶
Specify a custom variable name (elevation) for the input bathymetry:
topo-merge -v elevation -o merged_output.nc input1.nc input2.nc
Merge with Spatial Selection¶
Merge inputs within a specific polygon (polygon.dat) or frame:
# Using a polygon file
topo-merge -p polygon.dat -o merged_output.grd input1.grd input2.grd
# Using a frame (longitude: 0 to 10, latitude: 20 to 30)
topo-merge --frame "[0:10;20:30]" -o merged_output.grd input1.grd input2.grd
Merge with Depth Range¶
Only import depths between -1000 and -100 meters:
topo-merge -zmin -1000 -zmax -100 -o merged_output.grd input1.grd input2.grd
Convert Hydrographic Levels¶
Convert hydrographic levels to mean levels by adding a correction file (correction.grd):
topo-merge -add correction.grd -o merged_output.grd input1.grd input2.grd
Or by subtracting it:
topo-merge -subtract correction.grd -o merged_output.grd input1.grd input2.grd
Merge with Tagged Values¶
Replace a tagged value (-999) in the base bathymetry with input data:
topo-merge -b "file=base.grd variable=z" -tag -999 -o merged_output.grd input1.grd
Merge with Smoothing¶
Apply smoothing during the merge with custom parameters:
topo-merge -smooth-merge "zmin=-1000 zmax=-10 steepness=5 target=lower" -o merged_output.grd input1.grd input2.grd
Merge with Polar Grid Handling¶
Enable special routines for polar grids:
topo-merge --polar -o merged_output.grd input1.grd input2.grd
Replace Base Bathymetry¶
Replace the base bathymetry with the merged output:
topo-merge -b "file=base.grd variable=z" --replace -o merged_output.grd input1.grd input2.grd
Merge with Compression¶
Compress the output file with level 5:
topo-merge -deflate 5 -o merged_output.nc input1.nc input2.nc
Merge from a List File¶
Use a file (file_list.txt) containing a list of input files:
topo-merge -l file_list.txt -o merged_output.grd
Merge with Projection Parameters¶
Specify projection parameters for the input data:
topo-merge --proj="+proj=latlong +datum=WGS84" -iF NETCDF -o merged_output.nc input1.nc
Environment Variables¶
topo-merge uses OpenMP (version 201511) for parallelization. Key environment variables:
Variable |
Description |
|---|---|
|
Number of threads to use. |
|
Runtime schedule type and chunk size. |
|
Enable/disable dynamic thread adjustment. |
|
Enable/disable nested parallelism. |
Example:
OMP_NUM_THREADS=6 topo-merge -o merged_output.grd input1.grd input2.grd
Note: If running on a busy machine, limit threads to the number of free CPUs to avoid performance degradation.
Notes¶
Multiple
-addor-subtractOptions: If multiple-addor-subtractoptions are provided, only the last one is applied.Format Inference: Most formats are inferred from the file extension. However,
QUADTREEmust be explicitly specified using-iF.Projection Parameters: The
--projoption only works if-iFis specified. It may crash on mode 0 and 1 grids.Debug Mode: Use
-debugto enable verbose output for troubleshooting.Polar Grids: Use
--polarto enable special handling for polar grids.
See Also¶
Libproj4 Documentation (for projection parameters)
OpenMP API (for parallelization options)