Re: How To: Generate Superb Heightmaps :)
Posted: 12 Jul 2016 05:51
An HM I made for Train Fever that can also work here. Expect more to come soon. Also. Transport-fever.net is a great source for PNG heightmaps.
The place to talk about Transport Tycoon
https://www.tt-forums.net/
That's a great idea, +1Mr Bruco wrote:This is a video on how to create heightmap could be useful!
Hey friend, welcome to the TT-Forums!
look's like COVID 19 in microscopeKeplergamer wrote: 15 Jul 2016 20:59 Another 2, one with erosion applied and the other not. This time I tried to make it using a scale that suits OpenTTD maps, not train fever. OpenTTD 4k maps are like 30x bigger.
Try around 150-100 usable height for a 4K x 4K map.
https://tangrams.github.io/heightmapper/bba wrote: 25 Aug 2020 19:45 Hi everyone,
I have been working on a heightmap for Ireland, which I will share separately. I followed the Word document on the wiki to the extent possible. I would say it took me about an hour to get a heightmap that was maybe 90% of the way there, and then an entire weekend (and then some) to get it in a state I'm happy with. I thought it would be helpful to share what I found in case anyone else encounters the same problems I did.
- As others have noted, Topoview no longer seems to work with Google Earth, so I went directly to the CGIAR website at http://srtm.csi.cgiar.org/srtmdata/ and downloaded the relevant DEM files myself.
- Microdem works fine on Linux through Wine, but there are a couple of references in the Word doc to features that don't appear to be in the more recent versions of Microdem. Specifically:
-- There is no top-level "Merge" option in the "Data Manipulation" window. Instead, in the main window, just select "File -> Open -> Open and merge DEMS/grids".
-- I couldn't find any "Automatic choropleth palette" option in Microdem, as referred to in the Word doc. (It might have just moved / been renamed but I couldn't find it.) So I had to do the "original" method of selecting "Grey scale (monochrome)" and playing around with the z Range.
- In fact, I couldn't ultimately get Microdem (or QGIS, by itself) to output a greyscale image I was happy with. The problem seems to be that some very low land (eg, 1-5m above sea level in my case) gets rounded down to the same value as sea level when the raster is converted to a greyscale image. That means that some low land gets treated as sea in the resulting heightmap. I couldn't satisfactorily fix this issue without creating other problems, such as water being treated as land. Normally this might not be an issue, but for me it was resulting in peninsulas being rendered as islands and / or inlets being rendered as lakes. I eventually wrote a Python script to help solve this issue, by (1) setting all pixels with sub-zero elevation to zero elevation, (2) calculating the lowest elevation that is likely to be visible (non-zero) in the greyscale image, (3) finding pixels with an elevation above 0 but below that value, and (4) setting the elevation of those pixels to that value. I ran that script on the merged .ASC file before importing it into QGIS to convert to greyscale (Microdem continued to have issues distinguishing low land from sea even after running the script).
- To use QGIS to convert to PNG, I used the following steps:
-- In QGIS, from the top menu select "Layer -> Add Layer -> Add Raster Layer..." and choose your .ASC (or .TIF) file. It immediately appears as a greyscale image.
-- You may find that the image is a bit squished vertically, because by default it is displayed in the WGS 84 / Mercator (EPSG:4326) projection rather than the "pseudo-Mercator" (EPSG:3857) projection you may be used to. QGIS can be a bit finicky about how you change the projection. What worked for me was selecting "Raster -> Projections Warp (Reproject)..." from the top menu, choosing EPSG:4326 as the source CRS and EPSG:3857 as the target CRS and clicking Run. A new layer named "Projected" should appear. With the new layer selected, click on the projection button in the bottom left corner (it should say EPSG:4326, or at least it did for me), choose EPSG:3857 and click OK.
-- To export properly to PNG I had to follow the following steps (I don't know why I had to follow this rather round-about process, but it was the only way the greyscale image would turn out properly for me):
--- Right-click on the layer you want to export and select "Export -> Save As...". In the dialog that pops up, set the "Output mode" to "Rendered image", and choose where you want to save your layer as a .tif file. As well as saving to a file, a this will add a new layer in QGIS.
--- With this new layer selected, from the top menu select "Raster -> Conversion -> Translate (Convert Format)...". Click the "..." beside the "Converted" field to choose the file and format (ie, PNG) to export to.
- However, one feature from Microdem that I wasn't able to replicate in QGIS is the "Check Lakes" option. Basically, when you are converting to greyscale (or any other colour scale) in Microdem, you can tell it to check for lakes and give them a distinct colour. It does this by looking for contiguous sets of at least 9 "points" with the exact same elevation. This is helpful if you want to set the elevation of these lakes to sea level, so that OpenTTD renders them as water (only a good idea if the lakes are reasonably close to sea level in real life). I ended up writing a Python script to do this as well. It doesn't work exactly the same as the Microdem algorithm as it checks per-pixel rather than per-"point", so I had to use a higher threshold than 9 to get a reasonable number of lakes (I used 80 to get a reasonably good looking map).
- I used GIMP for the final image editing, rather than Paintshop Pro or Photoplus6 as suggested in the Word doc. I found the simplest way to do it in GIMP is as follows:
-- From the top menu select "Image -> Canvas Size..." which will allow you to choose the width and height of the image. Choose a width and height that gives you an image you are satisfied with while adhering to one of the aspect ratios supported by OpenTTD (1:1, 1:2, 1:4, 1:8, 1:16, 1:32 or the inverse of any of those). This will crop the image and / or expand it, filling in the new area with the colour of your choice (which should be #000000 if you want any new area to be sea). Click Resize.
-- Then from the top menu select "Image -> Scale Image..." and scale the image to the nearest resolution supported by OpenTTD.
-- Finally, select "File -> Export As..." to save the resulting image as a PNG.
So in summary, my process was as follows:
- Download the relevant SRTM data (as .ASC files) from the CGIAR website.
- Thin and merge the data files in Microdem, per the Word doc (I presume you could do this in QGIS and avoid having to use Microdem altogether; you can definitely merge in QGIS, though I don't know how to thin the data).
- Run fill_lake_elev on the merged .ASC file to detect any lakes and set them to zero elevation.
- Run fix_elev on the resulting .ASC file to bump any low land up to the minimum visible elevation.
- Convert the resulting .ASC file to a greyscale PNG using QGIS.
- Crop and scale the resulting PNG image to the desired resolution in GIMP.