am adding some diagrams here to help those new to it understand the effect of the terrain merge factor and also the landscape merge mask plane (if present)

the red line shows a diagram of a hypothetical terrain profile - the part with buildings is at nominal height above 0 - the edges below 0 - to form a hill effect. The green line shows the shape the battlemap terrain would have formed if the building/terrain wasn't there. The game places the settlement/building terrain so that it's nominal 0 height is at the average height of the battlemap under the terrain area.
If the terrain didn't have any merge factor applied to the outer vertex points then the result in game would be a cliff edge rising from the end of the red line where the terrain size ends up to the green line. However with a merge factor applied to the outer points so that they blend between 1 and 0 (white to grey on the wtbase.tga alpha) then the amount of effect of the terrain height is multiplied by the merge factor and so as it tends to a merge factor of 0 it blends back in to the battlemap profile, as shown by the dotted lines.

The effect of having a Landscape Merge Mask plane in the .worldterrain file (as is present in vanilla settlements) is that the 0 level is found from the average of the area under the Landscape Merge Mask size (that is a fixed hard coded size) the landscape merge mask is an entirely flat plane at what the game has determined as the nominal 0 height for the settlement. This plane is represented in the wtmerge.tga produced by the IWTE tool as a 256*256 pixel square. If that was an all white square (i.e. no merging) then you'd get a cliff edge up from where the blue plane ends going up to the green line of the battlemap.
If the mask is merged off to black, as with vanilla examples, then you get a resultant shape as shown by the dotted lines in the image above.
The effect of the Landscape Merge Mask plane together with the example terrain is shown below.
The settlement terrain (red line) still does the same thing, but it now blends with the result of the combination of the Landscape Merge plane and the battlemap.
NOTE: because the terrain shape is applied over the result of the other two files you'll only actually see an effect from the Landscape Merge Mask plane if the
effective* terrain size is smaller than the hardcoded size of the plane, as above we think the plane is equivalent to approx 128 as a terrain size.
*If the terrain vertexes inside the 128 area of a larger terrain have a low or 0 merge factor then some of the effect of the plane would come through as it will be merging to the result shown in the second pic...