News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

Links+Tutorial: Make heightmap of any part of world !

Started by dantedarkstar, May 16, 2009, 07:56:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dantedarkstar

Hello !

I have found a very nice thing when I was looking around the net for a heightmap of Poland.
It basically tells how to get a heightmap of ANY PART of the world ! (and to make a bitmap heightmap)
To make it even better, it's not the physical map with defined height layers (where larger and larger actual height difference is still a single "layer"), but the actual heightmap. And form what I read with about 90 meter resolution ! (so it may be even useful for getting the city heightmaps)

Here is the link:
http://gearsforums.epicgames.com/showthread.php?t=607176
And below are the instructions re-written by me according to my own experience and suited for Simutrans (after all Simutrans map is not unreal map or whatever).

-----

HOW TO MAKE HEIGHTMAP FOR ANY PLACE IN THE WORLD in 3 difficult steps ;)

EDIT:
Seems like I was a bit too hasty with writing the tutorial. Looking at the link provided by RanDrag (below), I learned that I missed the possibility to merge data files before making the heightmap.
So if you intend to make simutrans map out of multiple data files, AND you have lots of RAM, then the tutorial at http://www.tt-forums.net/viewtopic.php?f=29&t=27052 (provided by RanDrag) is probably better, since you don't have to "sew" the maps together.
However, when I tried to do my map this way, I "killed" my computer. After almost half hour of HDD drill I gave up and hard-resetted. Seems my RAM is hardly enough to handle 18000x12000 data sets (result of my attempted merging 3x2 sectors). So the "sewing" together described below still has its merits (if you have little RAM, or make monstruous map and would need to use tens of data sets at once).
/edit


Steps:

Step 1. Get the data.
You need to identify what data files you need. That's where Google Earth ( http://earth.google.com/ ) and a plugin for it ( http://www.ambiotek.com/topoview ) come handy.
Install Google Earth if needed, and then simply "using" (double clicking) the downloaded plugin should fire Google Earth with it. In the Places you should find a layer "SRTM4.1" consisting of "elevation" and two "logo" (which you should see on the top corners from the start). Anyway, enable whole "elevation" and you will see the Earth split into sectors, with "place" in the middle of each. The place will have name like "Data for: srtm_40_02".
These coordinates (40,2) are what's important for us, and for what we really need Google Earth.
Clicking on the place will open large window, where you could put the heightmap on the Google Earth globe, or more importantly (for us) find links to download source data for the whole sector (5 DEGREE TILE DATA, DATA tile in zipped ARCASCII format or DATA tile in zipped GEOTIFF format).
The link for ARCASCII is the same for all sectors, except for the very last part. The link looks like this for me (in the window it says download from London server, maybe for different places it will give different "best" links to download, don't know):
http://www.ambiotek.com/cgi-bin/downloadfile.cgi?url=ftp://anon:password@137.73.24.202/array1/portal/srtm41/srtm_data_arcascii/srtm_40_02.zip
(note: the above intentionally is not clickable link so that people downloading all needed things don't go for this by mistake)
The very last part is where the coordinates 40,02 are. You can use this link to download all needed sector datas just changing the numbers in the file name at the end. I hate Google Earth trying to act like an internet browser, so I just get this link and paste it into Firefox, instead using the link from Google Earth directly).
Anyway, now we have DATA !
Now, unzip the data into some working directory. Beware, the unpacked ARCASCII data are over 100MB for each sector. I haven't used GEOTIFF but it might be smaller.


Step 2. Make heightmap out of the data.
Tool:
For this step, the program MicroDEM is used ( http://www.usna.edu/Users/oceano/pguth/website/microdem.htm ). Just go to Download page and download the full installation. After that, also download the latest update (the first link on the Download page is full install, the second is the latest updated exe). Just put that new exe into the directory where you installed MicroDEM in the first place. I had to do that because the un-updated MicroDEM gave errors right at the start and didn't work.
What to do:
Start MicroDEM, close the small intro window. Now, open the extracted data. File->Open->Open DEM, then choose the right format for the data and open it (the second colorful button on the toolbar is same as File->Open->Open DEM). A window with the sector heightmap in colors should open after it finishes loading. This is our map. But it's in color, and we need a grayscale. And we also need it in a scale we want.
Setting the scale:
Since I used several data files to make one final heightmap, I had to take the scale into account. I used r-click on the map area then Modify Map Area->Set map pixel size, then entering the same number for all used maps. If you need a detailed heightmap you will need to use Modify Map Area -> Subset (graphical) & zoom to limit the map to a part you need before setting very small pixel size (if you do that from start it will say that it will require for example 17359MB for that, or simply say that he can't do that). Anyway, the scale one pixel size 1000 makes area of Poland a bit too big to fit within 512x512 map. But you can do whole sector with pixel size 100 or so to make huge and detailed maps (the initial data are 100MB not for decoration).
Setting the elevation scale:
Now, we need some fixed elevation scale. It is trickier than you might think. We need to take into account following things:
1.Maximum elevation present in the sector.
2.If using multiple data files - fixed same scale for all (so that the same height = same grey on all sectors).
3.Making land a land and making sea sea.
Anyway, use Modify->Elevation from the program menu, or use r-click and Display Parameter->Elevation. This will take us to the Elevation Map Options window. Here we define how the height is transformed into color. We need Gray Scale. There are also 2 other options we need to set: "Z Range" and "Missing" color. Since our data lacks sea height data, the "Missing" color is actually what color we want whole sea. I used pure Black to make maximally deep sea, or RGB (40,40,40) to make minimum depth sea (that's when you set minimal water level in Simutrans). The "Z Range" actually defines the range of heights that will correspond to grayscale 0-255 values. Set maximum so that it "catches" all the height present in your map/maps. If using multiple maps to create one final heightmap you must use the very same Z Range for ALL maps. But the trick is to make shores that are like 1 or 2 meters above sea actually shores in Simutrans, instead of some underwater reefs of coastal cliffs. Since we don't have any sea depth data, I used minimum sea level in Simutrans (-4, for experimental -10) to have largest possible height range above sea level. At this settings, gray somewhere around RGB=(60,60,60) arr just above water. But for a 1-2 meters height to become 60,60,60 we need to start the Z range below sea level, so that "zero" is already around 60 on grayscale.
The map I made had highest peak around 2500, so I put 2500 as maximum of Z Range. Experimenting a bit shown that -600 is good minimum for heightscale, because resulting gray shade for coastal flat areas are indeed coastal land area just above water. If you have different max, you will need different minimum to keep to "zero" in the same relative position along the scale. So your good "minimum" will be somewhere around YOUR_HEIGHT/2500*(-600), where YOUR_HEIGHT is the maximum you put in the Z Range.
Now, having thought this all through, we can apply the Grayscale and wanted Z Range to the map.
And save:
Now, when we have correct scale and height mapping to color, we can save the heightmap. R-click and Save Image. Save as any format you can read later, because it's not finished yet.

Step 3. Build the final heightmap for simutrans
We now possess the raw heightmaps we need. If you are making a simutrans map out of a single map file in MicroDEM and you are fine with the size as it is, then the map is ready (provided you saved as for example bmp that simutrans can use).

But if you want to resize the map and/or build one large map out of several heightmaps it is time for a graphic editing program (such as GIMP http://www.gimp.org/ ).
Just create a new large picture in Grayscale mode and open all the component heightmaps and paste them so that they match each other. If you are sewing maps together I hope you did all the component maps have the same scale and exactly the same Z range. If not, go back to Step 2 and do that again properly.
Anyway, if you used two or more heightmaps that are on the north-south axis you will be up to a surprise. The width of them is different !
The problem is, the southern parts exported from MicroDEM will be WIDER than the northern parts. This is due to the source files being constant width in Longitude (not distance). When drawing single map, MicroDEM keeps Longitude degree width constant (warping the map a bit). But due to that "horizontal scales" of maps neighboring on north-south axis will not match ! So before we "sew" the maps, we have to account for that. The simplest way, although not keeping the map perfect, is to choose one line (latitude) and stretch/shrink the maps that are norht/south of it (you can also shrink/stretch them just along the horizontal axis). Just look at the width of single map and stretch/shrink them according to that and they will fit each other like pieces of puzzle.
More advanced methods (probably required if making some large, especially if it's large "vertically" like Chile), would probably involve distorting each map so that it's wider at the bottom and narrower at the top, before sewing them together. Or using some real cartographic mapping (I'm not going to go into that).
Now, when you finally resized and sewn together all the parts, you have THE HEIGHTMAP. The only thing left to do is to cut out the actual part you want (I had to sew 6 sectors together, despite fact that the area was not larger than 2, because it happened to be on the intersections of sectors), eventual shrink to smaller size (if you made THE HEIGHTMAP huge and want only reasonable simutrans map) and put it into My Documents\simutrans\maps.
DONE !


Note:
I share this mehtod with everyone because it has two advantages over the way Joker described on the simutrans maps site http://maps.simutrans.com/tutorial.html
Advantage 1:
You get actual heights, NOT physical maps that often have height zones that are progressively bigger as the altitude increases (for example you have one step between 0 and 100 height, but only one step between 1500 and 2000 that's 5 times as large in reality). The physical maps often result in maps that are very rough in the flatlands, while the mountains are barely sticking out. Here, you translate real heights into simutrans heights on a linear basis.
Advantage 2:
You can get heightmap of ANY land on Earth except for subpolar regions. It has 90m horizontal resolution too, so even city-level maps can be obtained this way. It's much more detailed than simutrans' assumption 1 square = 1 km.

Of course it has also disadgantages:
Disadvantage 1:
Need to download lot of data.
Disadvantage 2:
Tedious sewing together to get larger areas.

Enjoy !

buwhahahaha  8)
Links+Tutorial: Make heightmap of any part of world !
http://forum.simutrans.com/index.php?topic=2210.0

Magpie

Very good tutorial for makeing a heightmap. I will just add a link to OpenTTD forum, with discussion about heightmaps for TTD (the first steps are same for Simutrans)
http://www.tt-forums.net/viewtopic.php?f=29&t=27052&hilit=microdem

Combuijs

For another tutorial on making maps for Simutrans, see http://maps.simutrans.com/tutorial.html.

I'm always interested in maps to put them on this website, so if you get any results, please inform me.
Bob Marley: No woman, no cry

Programmer: No user, no bugs



Carl

A quick point to add to this tutorial. There is actually no need to "sew" maps together manually in GIMP. MicroDEM will do it for you: Click File -> Open -> Open and Merge DEM, then ctrl+click all the files you want to add, and -- hey presto! -- the program will sew them for you. After you've done this, you can follow the MicroDEM instructions above to generate a heightmap. Note, however, that sewing too many files together this way is likely to lead to "out of memory" errors.

One other interesting point to note for Simutrans-Experimental users. The "set map pixel size" option is very useful, since it allows you to precisely set how many metres each pixel corresponds to. Whatever you set this option to, you should make sure it corresponds to the distance_per_tile / meters_per_tile value in simuconf.tab.

Jack Rudd

If I've got this right, this post has attached a Trinidad and Tobago map I made with this method.

Combuijs

#5
Well Jack Rudd, I think you have got it right!

Thank you for this nice map, I will publish it on Simutrans Maps, probably today.

Edit: It is in North American section of the site now. It took a while because I changed my Website maintaining program...

Edit2: And added to the blog, that went much smoother...
Bob Marley: No woman, no cry

Programmer: No user, no bugs



Svenson024

Hello everyone,


I'm trying to create a map of the Netherlands, a specific region called "Randstad". It is the busiest area in Holland which includes the cities of (greater) Amsterdam, Utrecht, Den Haag and Rotterdam. Also nearby smaller cities should be in it..

I have tried everything and I can't manage to get it right. Is there anyone who has more experience in creating this and could give me some help or maybe could upload it..?

Thank you so much in advance !!!

Greetings from Holland :-)

Combuijs

QuoteI have tried everything

You obviously did not try everything, as you would have found the solution already.  8)

What is exactly your problem?

(Greetings from Brabant...  :) )
Bob Marley: No woman, no cry

Programmer: No user, no bugs



rili

Hi people,
great tutorial from dantedarkstar. there is smth i want to add though...google maps strm plug-in is not working. Use this link to download the maps http://dwtkns.com/srtm/ by just clicking on the tile (region) of the globe that you need.

accord2

Hi, I need help. I followed all the post yet most of my map is underwater... Thank you :)
Son of a railroad man,  growing up in train stations, lover of trains

Carl

Check two things - first, when you load the ppm in an image editing program, is the RGB of the land areas at least 128, 128, 128? Second, try changing the water level in Simutrans map creation.

accord2

Quote from: Carl on June 23, 2017, 07:08:10 PM
Check two things - first, when you load the ppm in an image editing program, is the RGB of the land areas at least 128, 128, 128? Second, try changing the water level in Simutrans map creation.
But the land areas have different greys, how do I see the RGB? Yes I tried to change the water level, but I think most of the map was still underwater because of the half heights. Possibly I am doing something wrong, maybe the sea level is too high... ?
Son of a railroad man,  growing up in train stations, lover of trains

Vladki

Even if you set the lowest sea level, you'll still have sea in the darkest areas (about 20 shades of grey :)

Every decent picture editor has a tool to  show RGB values of given pixel.

Sent from my ONEPLUS A3003 using Tapatalk


accord2

Hi, the RGB have a lower value than 128, 128, 128. How can I change this?
Son of a railroad man,  growing up in train stations, lover of trains

Carl

Try adjusting the brightness of the whole image until the land you want to be coastal has a RGB of 128/128/128. This might take some trial and error.

accord2

Now the water is land and when i try to raise the sea level the continent turns water and the keeps being land :/
Son of a railroad man,  growing up in train stations, lover of trains

Carl

That's why it's a matter of trial and error - you have to brighten it just enough, but not too much :)

accord2

Son of a railroad man,  growing up in train stations, lover of trains