Home Tour Gallery Order Help Demo Plug-ins Dev Testimonials Mailing List

 


There comes a time when the DEM files you have are not the DEMs you want. Usually, you want to take two or more DEMs and merge them into one (DEM, by the way, is short for Digital Elevation Model, which is the geo-industry term for heightfield).

There are some programs out there that automate the process, depending on which format your DEMs are in. Doing it in Leveller is handy if you want full control over the process, so let's see how it's done.

If you are using an automated merge but want to use Leveller to clean up the resulting DEM, you may want to skip to the topic "Clean Up the Final Heightfield".
 

First Things First

Up front, we need to choose what dimensions the final heightfield will have. This determines if you will need to do anything beyond merely splicing the DEMs together. If you want to fully merge two 401 x 401 DEMs into a final 600 x 300 heightfield, obviously some downward resampling must occur. If you need to preserve the original DEM resolutions but have to crop out some unwanted edge pixels, then upward resampling must occur.

If your DEMs are large, you should verify that you have enough memory. Leveller will need to allocate memory for the largest DEM being imported, for the final heightfield, for the clipboard (which may match the largest DEM), and for a floating selection of the same size. Example:

Largest source DEM is 1200 x 800 pixels. Final heightfield will be 2000 x 1600 pixels. Largest clipboard transfer will be 1000 x 800 pixels. We will need, respectively, 3.66 Mb + 12.2 Mb + (3.05 Mb x 2) = 21.96 Mb.
 

Create the Receiving Heightfield

After choosing your final heightfield dimensions, create a new document of that size in Leveller (choose File, New and then Edit, Resize Grid...). This heightfield will "receive" the individual DEMs one by one. Save it to disk so that, after placing each DEM, you can immediately save your progress by invoking File, Save.
 

Create the Tile Heightfield

Now create a second Leveller document that can contain the largest DEM you will be importing. This is a "gateway" heightfield that simply lets you bring in the DEMs one by one without disturbing the final heightfield.


 

Import a DEM

Make the tile heightfield the active document. Use the Edit, Resize Grid command to make sure it is of sufficient size to import the DEM. Choose the relevant File, Import command for the source DEM.

Once the DEM is imported, you may need to do any of the following things:

  • Rotate the DEM to straighten it out. Use the Filter, Rotate, Other Angle... command to do this. It may take some trial and error to get the rotation angle just right. You can reduce the guesswork by selecting the Ramp tool and dragging a line from one corner of the DEM to another; this will report the angle of the line on the status panel. After releasing the mouse, choose Edit, Undo to undo the Ramp effect. For Leveller 2.0 users, we'll be updating the Measure plug-in to report angles.
     
  • Crop the DEM to remove unwanted void areas or other regions. Select the area you want to keep with the Rectangular Selection tool, and then choose Edit, Crop.
     
  • Resample the DEM to match the size it will have in the final heightfield. Choose the Edit, Resize Grid, Custom... command. Check the "Keep current elevation data" button, and the Resampling field should be set to Bicubic (best).
     
Usually, you won't worry about the vertical scale of each DEM. Once they've all been placed into the final heightfield, matching the elevations can be done there.
 

Copy and Paste the DEM

Now that the imported DEM has been massaged, choose Selection, Select All and then Edit, Copy to copy the DEM onto the clipboard. Make the final heightfield the active document, and choose Edit, Paste.

A floating selection containing the DEM will appear over the final heightfield. You may need to zoom and pan to see the floating selection properly.
 

Position and Defloat the DEM

Choose any of the selection tools and position the mouse pointer inside the floating selection. The cursor should change to an arrow. Now, click and drag the floating selection into the desired spot on the final heightfield. You can also "nudge" the floater into place by moving it in one-pixel increments with the arrow keys.

When the selection is in the right spot, defloat it by clicking outside the floater, or by choosing Selection, Defloat, Replace. The DEM will now "set itself" into the final heightfield. If you defloated badly, don't worry -- just invoke Edit, Undo, and paste the DEM again.

As we mentioned earlier, doing a File, Save at this point is a good idea.

You may want to use the Selection, Save Selection... command to save the selection marquee. That way, re-selecting the DEM tile for cleanup (see below) will be easier.

For the remaining DEMs, simply go back to the topic "Import a DEM" and repeat the above steps.
 

Clean Up the Final Heightfield

So now all the DEMs are imported. You can now close the tile heightfield's document window if you want. You can also release the clipboard memory by selecting a tiny region and doing Edit, Copy.

There will probably be visible seams between each placed DEM tile. The first thing to do is ensure that the elevation span of each tile is correct. To correct a tile's span, use the Rectangular Selection tool to select the tile, and then choose the Filter, Span... command. If you find making the selection difficult, you can also select just the tile's corners (select the second corner with the Shift key held down) and do a Selection, Rectify.

When the span for each tile is correct, any remaining seam problems can be fixed by sculpting.

A typical strategy here is to use the Rectangular Selection tool and constrain it to a line, and set the line width to two or to three pixels. Then, after selecting the tile seam, use the Filter, Smooth or Filter, Smooth More commands to blend the seam pixels into each other. The selection is also handy if you use the editing tools (Rubber Stamp and Smooth are popular here), because it will ensure that you don't accidentally modify pixels past the seam.

The worst problem is probably gapping -- you've scaled and positioned the tiles accurately, but there are gaps between them. The GIS purist will leave the gaps alone to preserve accuracy; the artist usually needs to fill them. Here, the Rubber Stamp tool and some creative sculpting need to combine.

At the end, we need to see if the final product looks cohesive (if that matters). If some tiles were made by significant upwards resampling (enlargement), they will look smoother than the other tiles. This can look unacceptable to some. There are three choices:

  • Select the detailed tiles and smooth them, to make them look "just as bad" as the low-resolution tiles. Most purists agree that this should be done only as a last resort.
     
  • Use the editing tools and filters (like Erode) to add detail to the low-resolution tiles. Here, the danger (if you are trying to remain geographically correct) is that you embellish the tiles with elevation data that doesn't exist in nature.
     
  • Hide the low-quality tiles with vegetation and other coverage effects when rendering. Most renderers can add fake detail as well, making areas look rougher than they actually are.
     

 


Copyright 2002 Daylon Graphics Ltd.