Tutorial 2: Merging Magnetic Grids
This tutorial steps through the required processes to merge 13 magnetic grids from the Eucla Basin area of South Australia. Where processes take a significant amount of time to execute, I've included an approximate time in parenthesis at the end of each step. The processing times are for a 3.6 GHz CPU with 8 cores.
If you encounter errors during the processing, then view the System Log File – File|View System Log File.
Processing Steps
- Run GridMerge – double-click the GridMerge desktop icon. Take a moment to familiarise yourself with the main window. You will notice that almost all the sub-menus off the menu bar are not enabled. These will be enabled once the Working Directory and Aliases and Parameters are set. We first set the Working Directory, then Check the Grids if this has not yet been done. Finally, we have to generate a Grid Priority Order, as a Priority Order File is required by some of the processes. We will then work through the requires processes under the Grid Pre-Conditioning, Grid Levelling and Grid Merge menus.
- Set the Working Directory – File|Set Working Directory. Navigate to the "eucla_mag" folder and click the Select Folder button. A message will be displayed in the Messages list box showing the Working Directory set. The Utilities menu items are now enabled.
- Check Grid Parameters – Utilities|Check Grid Parameters. On the Check Grids window use the File Icon buttons to select/specify the Input Grid Directory as "GRIDS_ORIGINAL" and the Report File as "report.txt". The Report File will be created if it doesn't exist. Click the Run button. On completion of the task, load the report file into a text editor to view the output. All grids should share the same projection and datum, have rotation=0 and zero for registration coordinate's offset.
- Create a Priority Order File – Utilities|Generate Priority Order. On the Generate Grid Priority Order window use the File Icon buttons to select/specify the Input Grid Directory as "GRIDS_ORIGINAL" and the Priority Order File as "priorityOrder.txt". The Priority Order File will be created if it doesn't exist. Click the Run button. On completion, you can view the grid Priority Order File in a text editor.
- Set Aliases and Parameters – Set Aliases And Parameterse|Set Aliases and Parameters. On the Set Aliases And Parameters window, click the Load From File button, then select the control file "gridMerge_aliases_and_params.pc" from the Working Directory.

Take a moment to study the aliases and parameters in the Set Aliases And Parameters window. The aliases and parameters are ordered by process – and in the order (top to bottom, left to right) that the processes are usually executed. You do not need to set all the aliases and parameters – only those for the processes we are going to run. In this tutorial we are going to skip Trim Grids to Coastline and Tilt Grids. Notice how any process that modifies the grids reads from an input directory and outputs to a different directory – i.e. grids are not updated. Note too how the output directory for one process becomes the input directory for the next process.
Select Save to save the current parameters and leave the window open. Or select Save And Close to save the parameters and close the window.
Tool Tip: If you've got space on your desktop, leave the Set Aliases And Parameters window open – it gives an ongoing quick reference to what the current parameters are for each process as you launch.
- Trim Grid Edges – Grid Pre-Conditioning|Trim Grid Edges. The process is launched. Grids are read from GRIDS_ORIGINAL, trimmed by 5 cells, and written to GRIDS_EDGETRIM. See the results in the User Log File. (13 seconds)
- Trim Grid Overlaps – Grid Pre-Conditioning|Trim Grid Overlaps. The process is launched. Grids are read from GRIDS_EDGETRIM and written to GRIDS_OVERLAPTRIM. Using the Priority Order File specified, the grids are trimmed according to priority – lower priority grids are preferentially trimmed. (7 minutes)
If, after trimming, a grid is all nulls, then it is deleted from the output directory and a warning message is displayed in the Messages list box.This means that you will have to create a new Priority Order for use with Get AbsoluteShift/Scale And Apply or Merge Grids/Feather And Merge Grids, as there must be a one-to-one relationship between the Priority Order and grids in a directory. It is also a good idea after trimming the overlaps to use the Create Jpegs From Grids utility to generate jpegs and identify which grids may require further editing. Use Boundary View (run on the overlap-trimmed grids) to see which portions of a particular grid are likely to contribute to the final merge. Then use Sub-Section a Grid to remove unwanted sections.
- Condition Grids – Grid Pre-Conditioning|Condition Magnetic Grids. The process is launched. Grids are read from GRIDS_OVERLAPTRIM, conditioned (to mean=0) and written to GRIDS_CONDITIONED. (5 seconds)
- Get Grid Overlaps – Grid Levelling|Get Overlaps. The process is launched. Grids are read from GRIDS_CONDITIONED, overlaps are calculated, and the overlap information is written to the binary file "overlapPoints.bin". We are not using control lines, so will have to specify base grids at some stage. (29 seconds)
- Get Relative Shift/Scales – Grid Levelling|Get Relative Shift/Scales. The process is launched. The grid overlaps are read from "overlapPoints.bin" and the best shift for each grid pair is written to the Overlap Grids File "overlapGrids.txt". (5 minutes)
- Get Absolute Shift/Scales – Grid Levelling|Get Absolute Shift/Scales And Apply. The process is launched. The best shift for each grid pair are read from the Overlap Grids File "overlapGrids.txt". The absolute shift for each grid is calculated and applied to the grids read from GRIDS_CONDITIONED, and the adjusted grids are written to GRIDS_SHIFTED. We are using grid "mSA1162" as the base grid to which all other grids are levelled. (14 seconds)
If one or more grids are not connected to the base grid/Control Line "island", then they will not be written to the output directory. In this case a warning message is displayed in the Messages list box.This means that you will have to create a new Priority Order for use with Merge Grids/Feather And Merge Grids, as there must be a one-to-one relationship between the Priority Order and grids in a directory.
- Merge the Grids – Grid Merge|Merge Grids. The process is launched. The grids in the GRIDS_SHIFTED directory are merged. The output grid "merge_shifted.ers" is written to the MERGES directory. (7 seconds)
- Feather and Merge the Grids – Grid Merge|Feather And Merge Grids. The process is launched. The grids in the GRIDS_SHIFTED directory are feathered and merged. The output grid "feather_shifted.ers" is written to the MERGES directory. (2 minutes)
Take time to view the User Log File – File|View User Log File.
Viewing the merged grids
- Load LHS panel grid – click the File Icon button to the left of the LHS grid text box to launch a Open File dialogue. Navigate to and select "merge_shifted.ers" from the MERGES directory. While this is loading, load a grid into the RHS panel as per step 2 below.
- Load RHS panel grid – click the File Icon button to the left of the RHS grid text box to launch a Open File dialogue. Navigate to and select "feather_shifted.ers" from the MERGES directory.
Use the Pan and Zoom to compare the 2 grids. If you completed Tutorial 1, you can load Boundary View to the LHS panel (and its associated Grid Information File) to identify any grids may be causing problems. You can view individual grids (one at a time) by clearing the display panels (Clear button) and loading the grids from the GRIDS_ORIGINAL directory into one of the panels. Alternatively, you can use the View Grid utility to view a grid.
Usually, when levelling artefacts remain in the grid after feathering it is due to one of the following:
- The edge of one of the grids is corrupted – trim more cells of the grid edge to solve the problem;
- There is insufficient overlap between the grids for feathering to be feasible/effective. In this case there is no feathering solution. You could try tilting the grids to get a better fit, or adjusting the weights in the Overlap Grids File to try and force the inconsistency to another part of the merged grid where feathering may be more effective.
Tilting Grids
If you need to tilt the grids, then (for a small number of grids) you can replace steps 10 and 11 above with:
Tilt Grids – Grid Levelling|Get Grid Tilts And Apply. The process is launched. The grid overlaps are read from "overlapPoints.bin" and the best tilt plane surface) for each grid is calculated. The plane surface is calculated and removed from the grids read from GRIDS_CONDITIONED, and the adjusted grids are written to GRIDS_TILTED.
For a large number of grids it is better to use the shifted grids as input to the tilting. In this case, rather than the above, you would add the following processing steps to step 13:
- Get Grid Overlaps – First open the Set Aliases and Parameters window. Change the Input Directory for Grid Overlaps to "GRIDS_SHIFTED". That is, we are going to use the differences between the shifted grids as input to the tilting. Change the Overlap Points File to "overlapPoints_shifted.bin". Click the Save button to save the changes. Now get the overlaps again – Grid Levelling|Get Overlaps to launch the Get Overlaps process.
- Tilt The Grids – In the Tilt Grids section the Set Aliases and Parameters window, set the Input Directory to "GRIDS_SHIFTED", the Output Directory to "GRIDS_TILTED", and the Overlap Points File to "overlapPoints_shifted.bin". Click the Save button to save the changes. Now tilt the grids – Grid Levelling|Get Grid Tilts And Apply. The process is launched. The grid overlaps are read from "overlapPoints_shifted.bin" and the tilted grids are written to "GRIDS_TILTED".
Merge the tilted grids (call the output "merge_tilted", say) and compare to "merge_shifted".
Care needs to be taken with Grid Tilting. If a grid overlaps on only one side, or the overlap area is small, tilts can be spurious. Study the output plane parameters (in the User Log File) carefully. If tilts are excessive, grids can be specified as "shiftOnly". As the name suggests, shiftOnly grids are constrained to a shift adjustment rather than a tilt adjustment.
Secondly, for a large number of grids (the Magnetic Map of Australia has more than 1,000 grids!), rounding errors in the inversion can be minimised by:
- first doing a shift as per steps 10 and 11 above;
- then calculating the overlaps again for the tilt as per steps 14 and 15 above.
Using Conditioned Base Grids
The final merged grids are at the same level (datum) as the control lines or base grid – whichever was used. If the base grid was conditioned prior to levelling, then the final merge will be level to this conditioned grid's level. In this case, there are two options for getting the merged grid to the correct level:
- Don't condition the base grid. Or after conditioning all grids, overwrite (using copy/paste) the base grid with the corresponding unconditioned grid from the input directory.
- Run statistics on all the grids in the input directory prior to conditioning (Utilities|Grid Satistics). Then, after merging, scale the merged grid by the base grid's standard deviation (radiometrics only) and add the base grid's mean (Utilities|Shift/Scale A Grid). For magnetic grids, use a scaling value of 1, as the conditioning does not scale the data. This will bring the merged grid to the same level as the base grid.