|
Processing DEM Data
Initial Conversion using 3DEM
Now that we have some terrain data to work with, we need to convert it to something usable in the Torque World Editor. Using 3DEM, we are going to
make our base heightfield graphic that represents the terrain elevations with varying shades of black, gray and white.
Start 3DEM and select File/Load Terrain Model.
In the DEM File Type Dialog, select the second option: SRTM Data (hgt, bil)
Click OK.
Browse to where you extracted the data you downloaded in the previous section and open the .bil file
What you will see next is a very cool Shaded relief map of your cell grid.
Now, I need to stop for a minute and talk about scale. As mentioned in the previous section, we are working with 7.5 minute gride cells.
What this means is our grid is 7.5 minutes square. A minute is a very small measurement of latitude or longitude. There are 360
degrees of longitude arond the Earth, each divided into 60 minutes. It works just the way you learned in high school geometry. And, yes,
in each of those minutes is 60 seconds. So, our grid contains roughly 1/10th of a degree of landscape. This corresponds to about
13,500 meters. So, our square is 13.5 square Km in size. But, our terrain grid in Torque is only 2 square Km. There are two ways
we can deal with this:
1. Don't worry about it. You can use all 13.5 square Km worth of land and squeeze it into your 2 squre Km Torque terrain and it will
work just fine and give you some very interesting and natural looking terrain.
2. Worry about it. If you really want to be accurate with scaling, then you'll need to cut out a piece of the map before converting it
to a height field. Doing some math, we find that 2Km corresponds to .0185 degrees. so, to cut out a 2Km square piece of our grid,
we need to cut out a piece .0185 degrees square.
If you look at the map in 3DEM, you will notice that when you move your mouse around, it shows you the current latitude and
longitude location of your mouse pointer down to four decimal places. Pretty convenient, huh?
So, let's do an example. Let's pretend our map starts in the lower left hand corner at 34.0000 latitude and -107.5000 longitude. to select
a 2Km piece, do this:
a. press the F8 key to start the area selection operation.
b. Line up the mouse precisely in the lower left hand corner so the latitude is exactly 34.000 and the longitude is exactly -107.5000
c. Click and hold the left mouse button.
d. Carefully drag up until the latitude reades 34.0186. Notice that we can't get exactly 34.0185 - the mouse position moves in .0002
increments. So, we'll be off by .0001 degrees. Close enough.
e. Now, drag carefully to the right until the longitude reads -107.4815. (We get this number by subtracting 0.0185 from -107.5000)
f. Check to make sure both the latitude and longitude read correctly as 34.0184,-107.4815 and let go of the mouse button
g. Press the enter key and voila, you have a 2Km square grid.
This procedure may seem tedious at first. If you are really gung ho about scale accuracy, just play with it for a while until you get the hang of it
Just remember you need a square that is .0185 degrees on a side.
Next, we need to convert the graphic to a grayscale height field.
a. Select Color Scale/Modify Scale from the menu bar to open the Terrain Color dialog.
b. Along the left side you will see the original color gradient scale.
c. Select the lowest elevation button and set it's color to black by setting all three color sliders to 0.
d. Click the highest elevation button and set its color to white by setting all three color sliders to 255.
Note: Setting the color gradient wide from black to white or narrow from dark gray to light gray doesn't seem to effect the color depth
of the final heightfield Torque generates when we import the final PNG image. Either way, the terrain elevation gradient is the same
in Torque. So, I just use black and white as my endpoints for simplicity.
e. Go back and click the lowest elevation button.
f. Click the "Spread To" button just below and to the right of the lowest elevation button.
g. Click the highest elevation button.
At this point, you should see a nice gradient from black to white going up.
Click OK to close the Terrain Colors dialog.
Our last modification in 3DEM is to get rid of the shaded relief shadows to get a true heightfield.
a. Select Color Scale/Shaded Relief from the munu bar to open the Lighting Parameters dialog.
b. Set the Shade Depth (%) setting to 0 to remove all shadows.
The end result is a pretty boring blob.
Next, we need to turn off the coordinate grid. If we don't, it will remain in our graphic and break our terrain. From the Geo Coordinates
menu, select Coordinate Grid Off and verify the grid and latitude/longitude numbers are gone. Don't worry about the little notched square.
This won't show up in the saved file.
Finally, save it out as a BMP file using the File/Save Map Image option from the menu bar.
Final Conversion Using Advanced Batch Converter
Our final step in getting a usable heightfield is to adjust its size and convert it to a PNG file. As noted in the Introduction, you can
use any image editor that will do these two things. I use Advanced Batch Converter because it's the first thing I found that does what I need.
Start Advanced Batch Converter and open the graphic you saved out from 3DEM.
First, we need to resize our graphic so it is usable in Torque.
From the Image menu, select the Resize option to open the Resize Image dialog.
Set both width and height to exactly 256. If necessary, turn off the Preserve aspect ration check box. It is important that our
graphic is exactly 256 pixels square. If we need to give up some accuracy in scale, that's just the way it is. One pixel corresponds to 7.8
meters, so a few pixels really won't matter that much.
Next, we need to convert our image to a PNG file.
From the File menu, select Convert.
In the file dialog, either select the PNG file format from the dropdown box or simply rename your file with a .PNG extension and click save.
And that's it for final conversion.
|