I'll be updating it over time if something is unclear or I find an easier way to do certain steps. I recommend everybody to follow the tutorial step by step. The method is rather experimental right now and there are still many mistakes to be made. And please always read the whole instructions before doing anything - I'm not the best teacher, so thing's might be a bit confusing otherwise.
Before we start: You'll need to install some additional programs: Google Earth, MicroDEM, OpenOffice (Microsoft Office/Excel will probably do the same, but I can't help you with that), Notepad++ (or another advanced text editor) and GIMP (or just use Photoshop, if you have it).
There's always a different way to do things, but this is what I'll use for the tutorial. Some basic computer literacy as well as knowledge of using text and image editors is required, but if you have any questions, feel free to ask in this thread or drop me a PM.
...Dear class, today we will be recreating Jamaica in 22 more or less easy steps
1. Get the import towns patch. Both the patch file and a pre-made windows build of it are attached. The patch was made by Zydeco and I don't own any of it (just to be safe...)
2. Download your heightmap data (detailed tutorial by MGSteve here). The file for Jamaica can be found here. When subsetting your area (described in the other tutorial), have a look at the status bar at the bottom of the window. It will show the size of your area. You'll want to make it as close as possible to your desired map size - if you want a square map, use a square. I used an area of 280x140km for a 1024x512 map. You need to be precise here or the coordinates won't match up later on.
3. Find your edge coordinates. To do this, select Info->Map window corners from MicroDEM's main menu. A popup will show you coordinates for the 4 corners and the exact center of the subset area like this:
Code: Select all
N18.70° W78.58° N18.70° W75.95° N18.075° W77.265° N17.45° W78.58° N17,45° W75.95°
4. Open a new text file (this will be your city data file) and insert the edge coordinates from the previous step as the first line. Save the file and get a beer or something - the easy part is finished
5. Go back to microDEM, make all necessary adjustments (see the other tutorial). Update: There's an easy method to get the sea level right without any experimenting. In the z range settings first select map area full range to find the maximum height, then select specified. Now you divide your maximum height by 15 (16 z-levels minus one for sea level) and enter the negative of this value into microDEM as minimum. For example, if your max height is 1100, your min height should bei -74 (73.3333, rounded up). Save your heightmap as a png image. You can exit microDEM now. We won't be needing it anymore.
6. Open the map png in your image editor and scale it (Image -> Scale image... in GIMP) to the required size. OpenTTD will do some scaling if the image is not the right size, but for the best results the heightmap should be 1 pixel = 1 tile, so I'll use 1024x512px. Keep the original file, though, in case you want to make a bigger version later on.
7. Save the heightmap, start OpenTTD, go to the scenario editor and load your heightmap to see if you need to correct anything in GIMP/Photoshop. When everything looks OK, save your heightmap again, close OpenTTD and GIMP and get some coffee. No more beer at this stage.
8. Download the allcities file from my dropbox. It contains data for almost 200000 cities in the whole world, so it's a bit too big to upload directly to the forum.
All the data is from http://www.geonames.org and licensed under a Creative Commons Attribution 3.0 License. I just extracted the data points that are useful for mapmakers from about 9 million rows of data... Such fun
9. Open the file with OpenOffice Calc and marvel at the load of data you've got. The columns are mostly self-explanatory. The feature code is a distinction between different kinds of towns. A list of the codes can be found here. A list of country codes can be found here. This is just FYI and shouldn't concern you right now.
10. Now we start filtering the data to remove stuff we don't need. To do this, click Data -> Filter -> Standard Filter in the main menu. Add the following filters: latitude > [your area's southern boundary] AND latitude < [your area's northern boundary] AND longitude > [your area's western boundary] AND longitude < [your area's eastern boundary] AND population >= [population of the smallest town you want to include]. If you want to make a map of one complete country (and nothing else), you can also just filter for your country code. This works well for Jamaica or other islands but is generally not a good idea.
11. Now we want to assign a size to our towns. The sizes are L(arge), M(edium) and (S)mall, just like in the scenario editor. First we need to decide which real world population should be which town size in the game. For Jamaica, I chose >20000 for large, >2500 for medium and everything else small. The right formula to do this automatically is already inserted in field B2. It says =IF(G2>200000;"L";IF(G2>35000;"M";"S")) and you only need to change the numbers. The first number is the minimum for large towns and the second one the minimum for medium towns. Everything below that will be small towns. So for Jamaica, the formula should be =IF(G2>20000;"L";IF(G2>2500;"M";"S")). To update the whole column with the changed formula, just double click on the litte dot at the bottom right corner of the selected field. My computer needs a few seconds to process everything, yours may take longer.
12. Next we need to define which of the towns should be cities. A 0 in the 3rd column means regular town, a 1 stands for a city. Again, the right formula is already inserted in field C2. It says =IF (OR(F1="PPL";F1="PPLX");0;1). This looks at the feature code column and looks for PPL (populated place) and PPLX (part of another populated place), which should be regular towns, and inserts 0 for them. Then it inserts 1 (city) for everything else, which are capitals and other important towns. If you don't like this selection and want the towns with the biggest real-world population to become cities instead, you can use the formula =IF (G2>[min population];1;0) instead. Don't forget to update the whole column again if you change the formula. Of course, you can also go through the list manually and just insert some 1s for the towns you like and 0s for the everything else - this should rarely be necessary, though.
13. Now select the columns A, B, C, D and E and press ctrl-c (copy). Close the allcities file without saving any changes. This is just your data source that should be left unchanged.
14. Create a new spreadsheet (ctrl-n) and right click on the field A1. Select Paste Special. Make sure that only Text, Numbers and Formats (and nothing else) are checked. This way, the results of the formulas are copied, but not the formulas themselves. If you just use paste instead of paste special, the formulas will be kept and try to calculate data, but fail horribly, because the cells with the population and feature codes don't exist anymore.
15. Click Data->Sort and sort your cities by size (ascending) first and city status (descending) second. When the biggest towns are at the top of the list, they'll be placed first. This prevents some small town to be founded first and block a more important town due to proximity. This can be very important in densely populated areas.
16. Save the file as Text CSV. Just use Save as... and select the right file type. In the following popup, set the character set to Unicode (UTF-8), field delimiter to , (comma) and text delimiter to " (quotation mark).
17. Open your CSV file with Notepad++. There should be 5 columns (Name, Size, City, Latitude, Longitude), nicely separated by commas and without any spaces or quotation marks. Select and copy all this town data. Paste it into the towns file that you created in step 4, just below the first line with the edge coordinates. If you want to add comments to your towns file, start a line with # and write whatevery you want. These lines will be ignored by OpenTTD.
18. In Notepad++'s main menu select Encoding->Encode in UTF-8 without BOM and save the file. Use a name without any spaces "jamaican towns.txt" would not work, but "towns-jamaica.txt" or "towns_jamaica.txt" is fine. Setting the right character encoding is very important... the patch seems to be a bit picky about that and will simply not work without the right encoding. When everything works, even towns names with special characters (ä, ö, ü, ź, etc...) should work correctly.
19. Now you can start OpenTTD, go to the scenario editor and load your heightmap. Make sure to select the right size, climate and "rotate counter-clockwise".
20. Open the console (press ^) and type "import_towns [yourfilename].txt" (without the quotation marks and with the name of the your towns text file, of course). Press Enter.
21. If you did everything right, there'll be no error messages and you'll have a bunch of towns in your scenario. The console will list all the towns that could not be founded (because of difficult terrain, closeness to map edges or other towns) and a sign will be placed in those locations. You just need to open the sign list (long click on the map icon), find the failed downs and place them manually (or just ignore them, if they aren't that important).
22. Place everything else that's needed for a scenario like additional roads, industries, trees and rivers. Save and have fun!
Making the relatively small and easy scenario of Jamaica took me less then 3 hours, including the time for writing the tutorial. It's still far from automatic, but a lot easier (and faster, too) than doing everything manually.
Thanks again to everyone who helped and inspired me and especially Zydeco for writing the awesome patch that made all of this possible... you're great!
If you encounter any problems (error messages during importing), please post your towns file and the exact words of the error message. "It doesn't work" is not a useful bug report and will not allow me to help you.
[21.oct.2013:edited with new, better method]
[28.oct.2013:optimized the method again with allcities file]
[29.oct.2013: replaced the windows build with a patched 1.3.2 stable]= [population of the smallest town you want to include][/b]. If you want to make a map of one complete country (and nothing else), you can also just filter for your country code. This works well for Jamaica or other islands but is generally not a good idea.