A shell script generates two the necessary two PNG files that can be used within OpenTTD. It automatically downloads the necessary files based on a few user parameters (description see below). In OpenTTD those files are used to generate a scenario in combination with a global town database.
NOTE: I started with a version that reads ASC-files, but this required a lot of memory. I discovered that it is also possible to download TIFF files that contain all height information. A shell-script combines the necessary TIFF files into a single PNG file, that can be used by the patched OpenTTD. The old patch is still available for download
An example map is shown below. An example map is shown below. You can create this map too, by following the steps below. Comments and suggestions are more than welcome.
What do you need?
- The latest patch (0v4, see below)
- Town information file. All towns of the world with a population large than 1000. Untar and place the towns_1k.txt in the "data" directory. (http://wwwhome.cs.utwente.nl/~wolkottep ... _towns.tgz)
- The example files of the region around the Alps. (http://wwwhome.cs.utwente.nl/~wolkottep ... europe.tgz). Untar and place the files in the "scenario/heigthmap" directory.
- The generation files to create the necessary files from a region anywhere on the globe.
Create PNG & info files
The patch uses three files (..._land.png, ..._water.png, and ..._info.real) to generate the heightmap and place water bodies. Those can be created by a shell-script that is included in the prepare_realistic_png.tgz. See the README.txt in the archive for more info. The shell-script also generates a fourth file, which can be used as a thumbnail.
The exact area you want can be selected in OpenTTD, however do not make the overall dimensions of the too large. I tested with input PNG files upto 6000x6000. The dimension of the scenario can be varied in OpenTTD independent of the input image size.
For this tutorial we use the available scenario "southern_europe" from my website (see above). Place the files
The town information
Place the towns_1k.txt file (in all_towns.tar.gz) in the data directory of OpenTTD
What to do in OpenTTD?
Start the scenario editor and select the new added button:
Select the generated real-file (this file links to the other two!)
A modified heightmap window will appear, where you can select the desired location of the to be generated map. The longitude and latitude of east/west and north/south can be changed in degrees and minutes. In the preview window the selected area is surrounded by the red rectangle.
You can disable the lattitude/longitude correction, but this makes the maps less realistic. This will change the preview too.
We modify the southern latitude to 41 and the western longitude to 1. The other longitudes are calculated automatically, because we have selected a square map size. Under the Long/lat correction you are able to change the anchor type, which results in a change of the longitude selection fields.
On the left bottom of the window height information is displayed. The histogram (i.e. bar graph) shows the height distribution. The height of the bars indicate the amount of pixels in the input PNG files (in a logarithmic scale). The white line indicates function that will be used to translate real height to the levels that will be used in the map that is generated.
Below this two extra options are included to modify the maximum height-level that is desired and the function that is used to transform the real height to the actual levels in the scenario. Try the two options to see the effect with the white line in the graph.
When you click on "Generate" a warning will appear:
We accept this warning for the moment.
Now you have generated a map, the water bodies can be placed. Select the land generation button in the top-bar
and select the extra button "Realistic placement of water" in the window:
The window will not disappear, but several water bodies are placed on the map. Water is only placed on tiles that were flat or have the good slope and that do not belong to the sea. In earlier versions the water was placed as canals, but currently I use rivers. Water that is directly connected to the sea becomes sea too.
Now you have generated a map and placed water, the towns can be placed. Select the town button in the top-bar
and select the extra button "Realistic placement of towns" in the window:
This will bring-up a new window. Given the previous selected longitude and latitudes all the towns that are present in the area are read from the towns_1k.txt file. You can modify the parameters to your own needs.
In the lower part of the window the histogram of the read towns is presented. This gives in idea of the amount of towns with a certain size. With the 4 popdown buttons you can select what the minimum population should be for a "small,medium,large town and city". An estimation of the number of generated towns is given. The actual number will be less (see below).
For each town type you also can change its initial size. It is possible to make very large "small towns" and small cities.
The two top options are discussed below.
D. Things to keep in mind
What happens when a town cannot be placed
It might be that a town location is on a slope or water. In this case the patch will try all 8 tiles that are surrounding the location. It all those 9 tiles are not possible a sign will be placed instead.
What happens with towns that are close to other towns or the border
With the top 2 options in the town generation window you can change the behavior of the placements of towns. The first option is the distance to the edge of the map. If a town is too close to the edge it will not be placed and a sign is placed on the map instead.
The second option is for the case two towns are too close to each other. Given that two towns are too close the population of both towns will determine the behavior of the placement.
A small town will disappear in a large town if their population ratio is more than 2. The population will be the sum of both.
If both towns are almost equal in size a new town is created. Its location is between the two towns, the population will be the sum of both and both town names are combined (largest town first). It is also possible that 3 or more towns are merged in this second case.
E. How does a final map look?
Below you can see a part of the screenshot of the southern_europe example files.
F. Where can I find more maps?
Several other maps I used for testing are available on my website http://wwwhome.cs.utwente.nl/~wolkottep ... enTTD/Maps
Future work, known bugs etc.
Known bugs / imperfections:
- The town placement goes wrong if the ratio of the selected area is not equal to the map ratio. [DONE, Selected area always equal to map ratio]
- I am not a GUI hero, the UP/DOWN buttons in the Town window are not working. [DONE.]
- I still am not a GUI hero, the filename and location of the town file is fixed to the data-directory.
- Adjustment of negative longitudes/latitudes via the text button do not work.
- The estimated number of towns in the gui does not include merges of two or more towns.
- Not all strings in the gui are correct. [Improved: work in progress]
- Improve code to the OpenTTD standards and better error handling (currently fprintf to stdout). [Work in progress]
- Increase speed. [Improved: Changed input from ASC to PNG]
- Correction of latitude and longitude lengths. [Almost finished: Tested for latitudes above and below equator. Not tested around the equator and below]
- Update to latest OpenTTD revision (rev 13922). [DONE.]
- Improve water placement [Check the connection with sea tiles. Can be further improved]
- Check the compile problems for Win32 with BuildOTTD
- Show a small preview of the loaded heightmap file, such that the total/selected area is visible [DONE.]
- Rotate the map
- More options for the height distribution (e.g. limit maximum height to 2000m) [DONE. Maximum level and transform function can be specified. More suggestions are welcome]
- Include water information. This will improve the coast line and makes lakes/rivers possible [DONE.]
- Include road information. For example to generate realistic highways
- Include industry information. Does anyone knows databases for this?
- realistic_map_and_towns_wolkottept_r13922_0v4.diff: 29 times
- realistic_map_and_towns_wolkottept_r13922_0v5.diff: 7 times
- realistic_map_and_towns_wolkottept_r13922_0v6.diff: 8 times
- prepare_realistic_png_0v4.tgz: 49 times
- prepare_realistic_png_0v5.tgz: 3 times