News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

Tutorial - High-resolution maps

Started by ZéQuimTó, August 29, 2014, 11:40:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ZéQuimTó

Ok, so I just found that people tend to spend too much work on creating maps, and I think that if people from the community just spend less time creating maps, not only we could have more maps, but also see people invest in other stuff, like creating savegames with cities etc..

This tutorial is litteraly a recipe: there is no need to "try things out", or tweak anything, like grayscale. Just pick the place you want, and voila, you get your map ready to go.

The tools you need for this are the following:
- Octave (On linux just get it from the repositories, on windows, just go here
  http://sourceforge.net/projects/octave/files/Octave%20Windows%20binaries/)

- Any image manipulation program to concatenate images together and save as .ppm, gimp is a good example. On linux, imagemagick (get it from the repo) could be easier (ill give the commands for it), but you can use gimp aswell.

Step 1 - Getting the raw data
First we need the raw elevation data. Go to
http://srtm.csi.cgiar.org/SELECTION/inputCoord.asp
select the tiles you want, on "Select File Format" choose "ArcInfo ASCII".
Download all your files to a folder, lets call it "simumap". Keep this folder on a path easy to access

Step 2 - After having all the files you want, extract all the .asc files to the "simumap" folder.

Step 4 - Download the file "srtm_process.m" from
https://app.box.com/s/0ke2obkt2cfdv0kkzjo1

Step 3 - Open octave, and go to that folder using the 'cd' command
  for example, if the folder is at "c:\users\x\simumap" then type
cd 'c:/users/x/simumap'
On linux is similar.

Step 4 - Open the file "srtm_process.m" and at the forth line, replace the filename of the file you want to process. Type it the same way as the one that's already there, i.e. without the extension.
Edit: Also set a maximum height for the map. Set the maximum height that you expect among all the tiles you got.

Step 5 - On octave, simply type (and press enter)
srtm_process

It will open a progress bar (may take a while), and at the end you'll get a .png file with all the appropriate height-scaling for simutrans. The sea-level must be set on -10.

Step 6 - Repeat steps 4 and 5 for every file.

Step 7 - Now you have one high-res .png for each map tile. We just need to concatenate all of them in one big blobby-bloated-oversized-map. You can use gimp glue them all together, scale down if necessary, and export as .ppm. If you prefer to use command line on linux, just jump to step 8.

Step 8 (optional, only for linux users) - we can stay away from gimp, and do everything using imagemagick on command line. When dealing with large files its easier this way.
Lets imagine that our files are called 1.png, 2.png, 3.png and 4.png, and that we want to concatenate them like this:
[1 2]
[3 4]

then just type:

montage 1.png 2.png 3.png 4.png -mode Concatenate -tile 2x2 big_map.png
convert big_map.png big_map.ppm
convert big_map.ppm -resize 50% medium_map.ppm
convert big_map.ppm -resize 25% small_map.ppm

If the files are too large, and you just want down-scaled versions, perhaps it would be wise to downscale first, and concatenate afterwards.

Step 9 - MANDATORY - Import the .ppm in SimuTrans and have Phun!!

Hope this helps bringing more maps into the community!

Cheers!


AltTab

Ok, here is a big question.

How sensitive is the height map? In another words, does this map include small but relevant local height changes?

I ask this because recently I made a map of Lisbon, but the "7 hills" are barely noticeable, due to the Sintra mountains. I was thinking of making a new one, only including the Lisbon area, so that this way the iconic height differences of the 7 hills city would be visible on the map.
I used NASA data crossed with flood maps to easily paint the different heights (it's sensitivity can be to 1 meter) I had to use 20 meters (i think) on the previous map, but this one (depending on the Highest point of Lisbon) I can increase the sensitivity to 10 meters or even 5 meters.

I want to know if your way can do this or it lacks this.

ZéQuimTó

Well, I guess you will have to check it for yourself (check the iberia map I uploaded on another thread).

This method, by using a sea-level of -10, and by scaling the highest mountain in the map to the full-scale, provides great height resolution. This means that low mountains may not show up if you have very tall ones, because the "full-scale" will be adapted to the tallest one. However, if the map has no oversized mountains, the small ones should be perfectly visible.

However, note that "iconic" mountains may not necessarily show up on a height map, as sometimes they are famous not for their height, but for any other reason. Not sure if that's the case.

Long-story-short: Try to check out the previous map I uploaded, and tell-me if the mountains are there, if they are, crop Lisbon out of it. If they are not (probably because of Serra da Estrela) please let me know, that I will re-render Lisbon alone, so that any mountains there get stretched to full-scale.

BTW, while writing this, I just noticed one problem with the auto-scaling of height...I was incredibly lucky on that map! Basically if we concatenate pieces which have very distinct maximum heights, the ground level at the junction edges could be different! :O I guess I will hard-code the maximum height and point that out in the tutorial.

Cheers!



AltTab

Well this last map had exactly the same problem I had in my first map of Lisbon. Due to high mountains I wasn't able to see the smaller ones. in Lisbon. But thank you very much for your try.

Quote from: ZéQuimTó on August 30, 2014, 02:43:34 AM
However, note that "iconic" mountains may not necessarily show up on a height map, as sometimes they are famous not for their height, but for any other reason. Not sure if that's the case.

The first thing tourists notice in Lisbon is the unusual height differences of the capital. Approaching Lisbon by boat and we can clearly see 3 different hills. Seeing historic buildings on the side of each hill makes Lisbon so iconic. The maximum height of Monsanto is around 200 meters (so they are nor very high) yet it shaped Lisbon in to a unique city, using it's "elevators" (special combination of 2 trams connected to each other to climb steep streets).

This is why I wanted to know if this method can be that precise.

kierongreen

If you play around with the brightness in an image manipulation program you might be able to get exaggerated heights at low levels while keeping higher levels not too high for Simutrans.

ZéQuimTó

#6
Quote from: kierongreen on August 30, 2014, 03:19:10 PM
If you play around with the brightness in an image manipulation program you might be able to get exaggerated heights at low levels while keeping higher levels not too high for Simutrans.

The octave script I uploaded does exactly that, it "increases the brightness" above sea-level to put the highest mountain at full brightness.
We have two options here AltTab: either you use gimp to increase the brightness just at those spots, or you use some sort of non-linear filtering. I guess a square-root filter, followed by scaling brightness to the full-scale, would increase the height of just the lower mountains. Try this out.
In the octave script, place this before the "if deepest < 0" line


img(img > 0)  = sqrt(img(img > 0);
img(img > 0) = img(img > 0)/max(sqrt(img(img > 0)))*16);

if you want to increase the effect, just repeat the first line a few times.


AltTab

Ok I'm giving up.
This and my technique (crossing flood maps with topographic maps) don't meet up what I wanted to do: a close to real life scale of Lisbon with according topography.


Rossio Plaza is only a block of 2 squares with your way, and with my way it's only 4 squares.

Well, I can try doing it manually, but I'm not that crazy xD

ZéQuimTó


Don't give up.
Lets put it this way: how large do you want Rossio to be?
Flood maps? Ill try to search for military charts that you could use as a data source.


AltTab

Well for scaling I was thinking of

Rua do Ouro - houses - Rua Augusta - houses - Rua da Prata - houses - Rua da Madalena

the houses could be 1 or 2 blocks, probably 2 would look  more "realistic".

Rossio only would be from Rua do Ouro to Rua Augusta, but both plazas would start from Ouro and end in Madalena.
So using that image it would be 10 blocks where the previous map had only 2.

Also the floodmaps help alot for imaging, but the resolution is too low
http://www.floodmap.net/?ll=38.720746,-9.058721&z=12&e=80

Besides some few maps, I usually use this site for having an accurate height of someplace:
http://elevationmap.net/praca-da-figueira-5c-1100-372-lisbon-portugal?latlngs=%2838.713509630827744,-9.13813591003418%29

ZéQuimTó

#10
Try here. you may need to download some software to open those files.
http://www.igeoe.pt/index.php?id=86

Let the force be with you! ;)


ZéQuimTó

#11
You know what?
I think we're on the same page here.
Just guessing, but, are you trying to make a realistic Lisbon map, with all the correct streets and so on, so that you can then manage the RL (real-life) bus/train lines?
If so, I think it would be quite productive for us to join forces. Let me put it this way: I know how to code, and I am mangling with simutrans code to generate maps automatically (plz, check my "Portugal" map, to see what kind of automation I am talking about).

Is that what you are wanting to do? If so, I have some ideas to help us out on making a city-map. The height map would be the least important stuff.

Greetz!


AltTab

Yep, essentially it's that.

I must say that I'm rather interested in the map automatic creation I will check ou....... WOW. Just WOW
Normally I create a map and manually input all cities, since Lisbon only have 53 parishes even if I include the South margin I would still have less than 70 parishes. And honestly, by hand it's not hard to do it. But knowing it's possible to do it automatically just got my attention.

Well, about coding. I lack at that skill, but other things, I wil be ready to help.

ZéQuimTó

Ok.

Well, I think that the most important features of a city map are streets, houses, and district names (by this priority).
Moreover, placing roads and houses on simutrans can be a difficult task, as so, my idea to automate this is the following:

It is easy to pick a google maps screenshot on a drawing program, such as Gimp, and draw the streets on a layer. The same goes for houses. As so, I will try to code something that takes streets and houses from a bitmap, and places them on a map.
This would make the design of a city (in this case, Lisbon) pretty straightforward.

To complete this project, I suggest you to do the following:
- Select a nice map-size (not too small, so that streets cannot be properly represented, yet, not too large, so that the map is unplayable). Something with 20M pixels is nice.
- Select a map region. I would suggest something that captures a little bit of the south margin (have some bridges would be awesome).
- After selecting these two things, post here your suggestions.

Then, take screenshots on google maps of all that region (in "map" mode), scale it to the proper resolution, and paint roads on a different, empty, layer. Make sure roads only have a single pixel width, and that there are no diagonals (my code will simply "paint" roads on those pixels, so, as you know, two roads on the diagonal do not connect. Use black (0,0,0) to paint those. For adjacent roads (roads adjacent, but not connected, like parallel ways on a wide road) use black(0,0,0) for one, and dark gray (10,10,10) for another.
Paint residential areas in red (255, 0,0), and harbour areas in green (0, 255, 0)
For places (e.g. "Vasco da gama", "Restelo", "Amadora", etc..) create a file with the following information:
"Name, X-position, Y-position"
where X and Y-position is the coordinate on the map of the given place.

Then upload these three files (heightmap, the color map and the .txt file with the locations) in a zip file, that I will generate a simutrans map. :D

What do you think? Are we up to this challenge?

Cheers!


AltTab

Ok, ill start doing it.

Also I'm posting here for the colour suggestion (and if it helps in anything else):
http://www.earthzine.org/wp-content/uploads/2011/11/fig-4.jpg

Im going to do it.

btw, can't we start a new topic for it. like project realistic Lisbon xD

about map size, that would be hard since I have to start making the map to say a size, or at least make a bit and extrapolate by scaling.

ZéQuimTó

Yeah, saw your pic. But remember that roads must be well defined, and single-pixel wide.

Ill start a new topic tomorrow when I find time for that :)

Cheers


DanteLives

I really like this script, but I am having an issue with the lowest land level. The map that I'm creating has a lot of water. The lowest level that is land is two levels above the water. I'd like to change the script to make it one level. Is there a way that I can do that?