Creating Heightmaps
Creating Heightmaps
superb heightmaps using satellite imagery downloaded from Google: http://www.tt-forums.net/viewtopic.php?f=29&t=27052 However, the forum topic is now several pages long and the original excellent description no longer works 100%. This wiki page is to consolidate and update the description. Its very worthwhile going through the forum topic though. The original text was provided by MGSteve (Aug 2006) but minor (and critical) bits have changed. Ive left his most of his own words but have edited to update to early 2008 and included additions by several authors; thanks to Ominus, Tegeltje and AndiK. Here goes. You will need the following: * Google Earth http://earth.google.com * MicroDem http://www.usna.edu/Users/oceano/pguth/microdem.exe (Oct 2007): * SRTM Overlay for GoogleEarth (Run from URL once you've installed Google Earth http://www.ambiotek.com/topoview). * A graphics program, such as Photoshop, Paintshop Pro, Photplus6 etc. * A fairly beefy PC, esp. if you are trying to generate a map covering a large (continents) area OK, before we start, make sure you've installed Google Earth, the SRTM Overlay & Microdem. Overview The steps involved are to find the DEM data for the area you're interested in. Load up Google Earth (GE) and if the SRTM overlay has installed correctly, you should have an SRTM2 category in the Places list in GE. Put a tick in the box next to SRTM2 and you should see loads of boxes appear over the globe, each with a green dot in the middle. If you click on the Green dot, you then have the option to download the DEM data for that cell. Once we have the cell(s) we need, we then need to load them into Microdem, reduce the definition of the data from really detailed to detailed enough for what we want. Once we've done this, we then merge the thinned DEM files into a complete DEM file, which we then load back into Microdem and then export it out as a PNG and then use it in OpenTTD! Sound simple? Yes? You're mad, its not simple its a ball ache! Anyway, here goes. Google Earth Firstly, if you're running NT4, Windows 2000, XP or Vista, you may want to enable folder compression in the folder you're going to save the DEM files to. Zipped the Dem files are 20odd MB, unzipped they're often 150mb, by using the built in file compression within NTFS, you save a fair amount of disk space. To turn it on, right click on the folder you're going to save the DEMS to (I'd recommend c:\Mapdata\DEMs\). Select Properties & then click the 'Advanced' button at the bottom, next to File Attributes. Put a tick in the 'Compress
contents to save disk space' and click OK. Done Now, in GE locate the area you want to generate a map for - in this example I'm going to do The Caribbean island of Hispaniola (Haiti & the Dominican Republic).
Now, on the pic, you'll notice the two green buttons for S_22_09 and S_23_09 - these are the two DEMs we'll need. Click on the Green buttons and you'll see a page pop up, scroll to the start of the links and you'll want to download either of the first two links (Either from the US or UK Servers, it doesn't matter), its the data file in ARCASCII format. Save the files into the C:\mapdata\dems\ folder. Once you've done that for both DEM cells, close GE, you don't need it any more. MicroDem Unzip the DEM files and then fire up MicroDem. Click on File->Open DEM In the Files of Type box, make sure ASCII Arc Grid (*.asc) is selected, browse to the folder and select either of the two files. Microdem will now load the DEM file. By default you get all the legends and other stuff you don't need, to turn these off. You'll only need to do this the first time, as it remembers these settings. Right click on the map & select 'Legends / Marginalia'. Click on 'Scale Bar' and untick the 'Include on Maps' box. Do the same
with the Elevations button. Then click OK to close the Map Marginalia window. Right, by default the DEM files we downloaded are way too detailed to be of use, so we need to 'thin' them. To do this, select Raster Gis--> Thin DEM (Decimate) Select a Thin Factor of 3. Then click File-->Save DEM-->ASCII Arc Grid. Save the file under a new name in the same location as the maps (S_22_09_Thin.asc) is a good suggestion, basically just add '_thin' to the filename. Close the two Microdem map windows & repeat the process with the 2nd map. (Or as many maps as you need). You should now end up with a 'thin' DEM file for each of the cells you have. Note, the next step is to merge the DEM files into one single file. The program does have a limit to the number of columns and rows of data it can handle in a DEM file. If you find that you are exceeding this limit (default at a thin factor of 3 would result in a maximum grid of 12 cells x 12 cells. (24000x24000). If you are needing more cells then you will need to thin by a factor of 4 or even 5. Don't worry about the degradation in quality of the map, as you're using so many cells it won't matter. Ok, make sure that you close all open windows in MicroDem first, then from the File menu select 'File->Data Manipulation'. On the new window, select 'Merge->DEMs'. Browse to the two 'thin' files you saved and select them one at a time, pressing 'Open' each time. This will add them into the merge list. When you have added the last file, click 'Cancel' on the Open dialog. Microdem will then ask you for the name of the file to save to, save it into the same folder under the name of Hispanola.DEM (obviously change this name if you're not doing hispanola).
Now load up the saved DEM file by clicking 'File->Open DEM', change the Files of Type list to 'Any Likely DEM'. You should now see the two DEM cells merged into one.
Right, we now need to crop the map to the area we want. On the tool bar of the Map window (not the main Microdem toolbar), you'll see a button which looks like a dotted rectangle with an arrow at the bottom right (7th in from the left). This is the create subset button, click it and then click and drag across the map area (You must click & drag from the top left to the bottom right of the area, if you do this wrong, you'll get a message anyway.). Microdem will automatically zoom into the cropped area. If you made a mistake and cropped off an area you want, simply undo the crop (the crop operation is called a subset), by clicking the 'undo subset' button (to the right of the create subset button). Final cropping is often better completed in your graphics program, as you will need to have approximately the same dimensions in pixels as one of the input options in OpenTTD
Right, now we need to change this to a grayscale map. Right click on the map and select 'Display Parameter' and then from the popup menu, select 'Elevation'. There are two optional ways to continue. The first is the original, provided by MGSteve Select 'Gray scale' from the list of radio options and then click on the Z Range button. The Z Range basically controls how the heights are mapped onto the grayscale colours, the greater the height, the lighter the colour. Normally you'll want to select the defaults, but if you find the OpenTTD doesn't get the coast lines right, its probably because the ground is too dark and OpenTTD can't tell what's land and what's sea. If this is the case, lower the Max value until the problem goes anyway. You may also want to lower the Min Value too, as this will effectively start 'sea level' at a lower position on the map. In this case we need to tweak these values, so enter a min of -150 and a max of 2500. Click OK and then OK again and the map will redraw. Alternatively, and very simply, provided by Ominus There are 15 heights in OpenTTD; each has a specific grey color for each height; Code:
LVL 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
R 30 40 50 70 90 110 120 140 150 170 190 200 220 230 250
G B ||30 ||30 ||40 ||40 ||50 ||50 ||70 ||70 ||90 ||90 ||110||110 ||120||120 ||140||140 ||150||150 ||170||170 ||190||190 ||200||200 ||220||220 ||230||230 ||250||250
How to use these in Microdem When you are in the Elevation map options window, choose Automatic chloropleth palette, its at the bottom. Then from the list find "Green to Magenta, 16 steps" and click the define button, you should leave the MAX and MIN list alone since it adapts to the dem file. Now you should enter the OpenTTDvalues from top to bottom, the highest color being the lowest height. Since the palette has 16 steps you just enter the same value in the 16th step as you did for the 15th step. Click OK and then OK again and the map will redraw.
Finally, We need to resize the map to 1:1 pixel mapping. To do this, on the map window's toolbar, you will see zoom and unzoom buttons, between them is a number 1 in a magnifying glass. Click this button. You may or may not get a warning about memory usage, depending on the size of the DEM data, but its not that much of an issue. Now we need to save this out. Tegeltje provided this to replace the original text : the option "Save image" when you right-click on the heightmap will allow you to save the image in a variety of formats, including PNG. Enter an appropriate name and click save. Now fire up the image editing software, for this tutorial, PaintShop Pro was used. Photoshop would do as an alternative. Some tips are also given for Photoshop 6 which can be downloaded free if you dont mind some emails asking you to spend US$10 to upgrade: http://www.freeserifsoftware.com/software/PhotoPlus/ Open the .png file. The next thing we need to do is try and match the resolution of the file to the resolutions of the OpenTTD maps. You need to crop and/or resize the image to either square or rectangular with close to one of a combination pair of 2048, 1024, 512 or 256 pixels. Using Paintshop Pro
You need to work out the best image size for your final map. This particular example is pretty much an obvious 1024x512 map size. For land locked maps (i.e. with no sea on one or more sides, its imperative that you match the image size with the map size, otherwise you'll end up with sea off the side of the map. We can resize this map to 2048 x 1024 This will need a bit of cropping and resizing to do it, so I'll leave it up to you as to how you do this, as it will really depend on how tightly you cropped the DEM file. What I did was to resize the width to 2048 and then resize the canvas to 1024, so it added more sea to the top and bottom of the image. Now click File- ->Save As and save it as a PNG file. Probably best to save this in OpenTTD's heightmaps directory. Or, using Photoplus6 You can crop using their cropping tool (3rd one down on the left) remember if you hold down the CTRL key cropping is carried out as square. Double click to crop. Alternatively you can crop to a specific number of pixels from the top left corner of the image. Select Image - -> Canvas size, then enter the desired number of pixels for height and width. Photoplus6 can stretch or compress the image to OpenTTDs desired dimensions, Select Image --> Image size To save the file Select File --> Export and save it as a .png file again.
Either way, there you go, one heightmap! Load it up into the scenario editor in OpenTTD (remembering to select the right map size, in this case a 2048 x 1024 heightmap would equate to a 2048x1024 map for the best quality, or a 1024x512 map or a 512x256 map. As long as the ratio stays the same, it will be fine If you find that the shorelines have crept inland a bit then you'll need to go back to the step where you created the grayscale map and alter the Z range numbers a bit. Alternatively, in the image editor software you could try selecting the sea, inverting the selection and altering the gamma of the land, effectively lightening it. As you can see from the finished map, by comparing it to the Google Earth image, it hasn't quite got the north coast quite right. Its probably quite low lying land. You can either fill gaps like this in by hand or simply re-tweak the grayscale map and try again.
AndiK adds I've played around a bit with the DEMs you can get via Google Earth. I found out some stuff that might be useful for other people who want to create nice height maps:
An area of about 200 x 200 km for a 2048 map fits very well into OTTD's landscape measure. In a hilly or mountainous area, you will get both steep hills and nice valleys. If you cover a larger area, the valleys will get too narrow to build anything in them. A smaller area stretches all hills and mountains so much that they are no obstacle any more. -> Boring. A vertical height spread (meaning: Difference in height between highest and lowest point on the map) of about 1000m seems best for OTTDs landscape measures.