Importing real life geography into LevellerThis tutorial looks at importing real geography into Leveller (a powerful 3D terrain editor for windows from Daylon Graphics) for later use in OpenSimulator (Opensim). Unlike the previous tutorials, which focus on specific tools or processes, this is more about making decisions on how to import and how to modify the results of that.
Elevation and Image formats
Leveller imports a variety of elevation formats. For a complete list of this see Supported Elevation Formats on the Leveller site. Leveller can also import the image formats as heightfields, see Supported Image Formats. If you examine both pages, you'll notice that there's an overlap between elevation and image formats. These formats were used as a convenient way to encode height values into images which could be edited later. We'll be using terrain.party to generate 16bit PNG files for us, which can be used as both a graphic and a heightmap. This online application allows the user to select a portion of the map of the earth and generate a series of PNG files that you can import into Leveller. The reasons for using this online application are:
- It's free to use;
- PNG format can be viewed as an image;
- Files can be generated from anywhere on the Earth ; and
- It's simple to use.
You can search by name for a location, zoom in or out, and scroll around the map of the Earth by dragging the mouse. You can also decide which which overlay to use, though the two USGS options only work in the USA and territories. You can also decide how large the selection area is and place that where you want, though it doesn't move unless either you manually move it, or your text search moves the map to a location.
Examples usedWe'll be using two examples for this tutorial: Saint Helena, and Rottnest Island. All examples are islands because their coastlines give a clearly defined area to work with.
St HelenaThis island lies in the South Atlantic Ocean and is famous for being where Napoleon was exiled after the end of the Napoleonic Wars. It was settled by the Portuguese and British, and is currently a British Dependent Territory.
|By Oona Räisänen (Mysid) - Self-made in Inkscape. Based on several sources:CGIAR-CSI SRTM 90m DEM Digital Elevation databaseSRTM30_PLUS bathymetry by Scripps Institution of OceanographyTopographic map of Saint Helena by Barry Weaver and Jean-Pierre LangerSaint Helena Island, a photograph by NASA Earth Observatory, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=11135951|
In terrain party, it looks like this:
Now the smallest selection size that will cover the island is 20km. Below we see a comparison between that, and the largest possible selection of 60km:
We'll make two downloads, one at 60km, and another at 20km, to show the difference. You download by pressing Download button on the map, choosing a filename and saving to an appropriate location. All downloads are ZIP files so you need to open that and inspect the contents:
The image above shows the contents of saint helena 20km terrain.zip. Opening the saint helena 20km README.txt file, we can read where the zip came from, a URL (e.g. http://terrain.party/api/export?name=saint+helena+20km&box=-5.612559,-15.871623,-5.799511,-16.051286) we can use want if we want to export this again, and information about the heightmaps (PNG files) included in the zip. The Height Maps section lists details about the ASTER, SRTM3 v4.1, and SRTM30 Plus PNGs. These are all different sources for the data with different resolutions and accuracy. The saint helena 20km Height Map (Merged).png file is a merging of all of these, and in all the examples we'll use the Merged versions of the PNGs. The Elevation Adjustment section of the readme file gives us information about the range of elevations in each heightmap (in this case 0 through 1250 meters), and advice on transforming these values for "the game" (which is cities:skylines). Lastly there's the Missing Data section, which informs you if there's missing data on any of the maps. You'll find missing data on all the PNGs in all the examples, because no data is included for ocean areas (hence the zero height value).
If we open saint helena 60km Height Map terrain.zip and read the readme file, it says...
No height map data was available. That's a bummer.
If you're way at the poles, that's probably why. Orbital measurements only go
so far away from the equator.
If this area is filled with water, try a box that has less water. That's
probably a good idea for gameplay reasons anyway.
...which is annoying, but at least it tells you why it failed. In any case, our available PNG file looks like:
The bitmap image is 1081x1081 in size and 8bit. To import this into Leveller, go to File > Import, and select the PNG option. Then load the saint helena 20km Height Map (Merged).png file, and you should see something like this:
As you can see, Leveller wants to know the elevation range. Terrain party reported this as being 0m to 1250m, but that will need to be adjusted. There's no need to change the zero, because that's seal level where the "missing data" lives. Now 10m might be a an OK guess, but we need to consider the scale factor. The 1250m maximum was for a 20×20km - or 20000×20000m - area. Assuming that 1px = 1m in Leveller (that can be changed) then that means the image is 1081m wide, so the map has been scaled down to 1081/20000 or to 5.405% If we multiply the maximum height by this, we get 1250 times 0.05405 or 67.5625, which we'll round up to 68m. Enter that as the second span value, select OK, and we get:
This is a standard confirmation screen, which appears when you're importing a terrain over a certain size (starting at 1024, but this can be changed in preferences). We'll press OK, and this takes us to the next dialog:
Because the terrain file's above the limit, this dialog needs you to select which area to import. You can do this manually with the Edit button, or dynamically with the selection marquee. You can also resize the terrain during import by ticking Downsample and selecting a % to downsize to from a drop-down menu. We'll skip both and instead dynamically select all using the marquee. It should now look like this:
Select OK, and the resulting map looks like this:
What's that bite in the South East? If we look back to the PNG we can see that it was on the image. When looking at the scene pane, we see:
Clearly there are errors in the merged version of the heightmap (red arrows). After a search on the net to find an aerial photo of St Helena...
...we can see that the spikes on the West and North coasts are aberrations (probably in the original data of one of the sources), the bite in the South East is missing data, but close to the actual coastline. However, the cliffs in the South West are actually there!
There's several options now. You could:
- Try one of the other PNGs;
- Try another download using terrain party;
- Fix the aberrant and missing terrains manually, using the photo as a guide; or
- Find another source of data that is more accurate and complete.
...provided by the Shuttle Radar Topography Mission but SRTM3 v4.1 is the result of considerable effort from CGIAR-CSI. It has a ~30m resolution in the US and a ~90m resolution elsewhere.
...so it might be the more accurate of the PNGs. Viewing the PNG itself...
..we can see that there's no spikes (white patches), and that the South East corner is intact. We'll follow the same routine as listed above (with a range of 0 to 68 elevations), and the result is:
This is looking better. The fringe around the island is possibly where the radar gave an indeterminate result. We can easily get rid of it however. First we move the cursor around the map to check the height of those areas:
It varies but never goes above 4m, so we'll select Filters > Elevate, and Lower by 4. As we have nothing selected, this will lower the entire heightfield by that much. The new map now looks like:
The small islands around the main one, might actually be tidal in nature, or it could just be the radar going wacky. You can always edit them out manually. The blue sounding area now shows because the points that were zero are now -4, below the water line. Here's what the scene now looks like:
You may need to fiddle with this further. For example, is the height scale correct? You can change that using Filter > Span. However it's a bit hard to fully appreciate the scale here. Perhaps you want to export it to Opensim first to see how it looks in relation to an actual avatar? In that case we need to fix the size of the document.With a 1081×1081 size, that's just above 1024×1024. That could be: one large 1024m² region; 2×2 512m² regions, or 4×4 256m² regions. The first step would be to crop the document to 102×1024. To use Edit > Crop, you need to have a rectangular area selected. You can either do that manually by using the Select tool, or by using Selection > Select Area option. We'll do the latter for precision.
Select OK, and this dialog appears:
We want to Replace as shown. Select OK and you now have the following selection:
Now select Edit > Crop (or press Ctrl + R) and we get (after I adjusted the guidelines):
Of course you could also shrink or enlarge the document as well. The upper practical limits on document size, according to the official FAQ, is about 6000×6000 for the 32 bit version, and 12000×12000 for the 64bit version. The amount of memory you have on your PC will affect performance as well.In any case, suppose you only want a single 256m² using this map. You can resize a whole document by using Edit > Resample. This brings up a drop down list of choices:
The size we want - 256×256 - is on the list so we can select that. The result is now:
Before anything else, I would do a File > Save As and save the re-sampled version as a copy of the original. If you don't, and later want to resize it again, you will have lost data in the sampling down of the document, and would probably have to import the PNG again. Or, you can do an Edit > Regress To. This brings up the following dialog:
In the example above, you could just select Select none of heightfield, or Initial state, and Leveller will recover the original version of the document. Often this is a lot easier, and quicker, than doing a Ctrl + Z (Undo). So, we have our original size restored. What if we wanted to resize to a value not on that list? In that case we'd select Custom on the resampling list, or just Shift + S at any time. This brings up this dialog:
As you can see, we can use any value for width (the horizontal size of the map) and breadth (the vertical size of the map). If these new figures aren't proportional to the originals (e.g. 1024, and 512) then that will change the proportions of the terrain. You may need to use the calculator here to get values for non-square documents. Pressing F1 (as it will for most dialogs) will bring up a HTML help page in your browser, including an explanation of the differences between Plain, Bilinear, and Bicubic resampling. We'll change the size to 4096×4096, leave the rest as is, and get:
The resize worked, but the elevation values stayed the same, so the result looks very flat. We'll Undo to the previous state, resample to 4096×4096 again, but this time tick the Keep elevations proportional box:
This is better than before, but the flat bits around the coast have also been raised and raised above the water level (still zero). An inspect of those shows that they never get above 12m, so if we do a Filter > Elevate with Lower and 12, we get...
Much better! As you can see, the the coastline's been restored.
Rottnest IslandRottnest Island (known as Wadjemup to the local Noongar people, and otherwise colloquially known as Rotto) is an island 18km off the coast of Western Australia, and due west of Fremantle. A sandy, low-lying island formed on a base of limestone, Rottnest covers 19km². We'll be using Rotto as our second example in importing real life terrains.
|By Moondyne (openstreetmap.org) [CC BY-SA 2.0 |
via Wikimedia Commons
Here's what Rottnest Island looks from the air:
|By Created by the uploader. |
Any IP involved in the creation of this image is released into
the public domain. [Public domain], via Wikimedia Commons
Rottnest varies in from Saint Helena in several ways: it's nor round, squarish shape, it's a generally flat area, and it has several lakes and reservoirs.We'll address these issues, as otherwise importing the terrain follows much the same steps as St Helena. Using terrain.party, we can see that the whole island can be covered using a 12km selection area:
We could use a selection of 11km, but that cuts very close to the coastline of the island. Downloading that selection we open Rottnest Island 12km terrain.zip and find the ASTER 30m, SRTM3 v4.1, SRTM30 Plus, Merged, and Readme files. The Readme file tells us that the files were made from the http://terrain.party/api/export?name=Rottnest+Island+12km&box=115.568385,-31.952871,115.441188,-32.060669 selection, and that the height ranges are between 0m (coastline) and 82m. After inspection, the Merged version of the PNG looks like the best one to use.
Once again the image is 1081×1081px (a standard size with terrain.party) but instead of a 20km selection as we used with St Helena, this selection is 12km. That gives us a ratio of 1081/12000 or 0.0900833333333333 which we can round to 9%. Multiplying 9% by 82, we get 7.38m for the highest elevation. Our import dialog should look like:
We select OK, and also OK the Proceed with Import dialog that appears (because the size is larger than 1024 a side) after this . This then brings up the following dialog:
Rather than accept the default, or select all of the imported terrain, we'll select a custom are, as below:
The map of this (with 1px and 256pm guidelines) looks like:
As you can see, you could export this using File > Export tiles as either a 4×2 tileset of 256m², or a 2×1 tileset of 512m². The scene looks like:
We still have the same issue that St Helena had. The ocean areas here are really zero elevation, and the coastline looks like there's a shape drop. This means that if exported this into Opensim, the ocean would be either all at 20m, or 0m! Moving the cursor around the coastline of the map, we can see that the heights are between 2.1 and 2.9. If we do a Filter > Elevate with Lower and 3, we get:
Clearly a value of 3 is too much. Next we'll Undo, and try the Filter > Elevate with 2.5:
This is better! Of course we could instead raising or lowering the elevation of the entire heightmap, change the Water Level. You can do this by using Edit > Water level > Elevation and entering a new value, or by using the Water Tool and moving the mouse. We didn't use either of these, because as we're exporting later to Opensim, we want the water level to stay at zero. See below for fixing the ocean height levels properly. Rottnest lies on a coastal shelf, but that's more than 2.5m deep!
But, what about the ocean?!
There's one thing remaining before we can export these documents to Opensim - the ocean. In both cases the heightmap imported via the PNG file has "missing data". There were no values for any of the water areas, so these were "zeroed out" and shown as 0m. Over the course of fiddling with the documents both heightfields were lowered using Filter > Elevate, so that what was zero is now a negative value. While that might look OK in the Scene pane, it's going to flat and either very shallow or very deep. Either way that's not very natural looking.
So, we need to modify those areas, but at the same time not modify the land area that we've taken care to import intact. The easiest way is to use shapes as contours to generate terrain in those areas, and to also use a selection to make sure that it's only those areas affected. Before you continue, go read Part 3 about how to use shapes as contours in Leveller. Pause. Now that's done, consider what we need for Opensim. Usually in Opensim the water level is set at 20m. and the bottom of a region is 0m. You can go lower than that by manually lowering terrain using the Edit Land tools, but anything lower than zero tends to be a dark murky unreliable space. The following image shows the Master Builder avatar standing at -9m in a test region. Not pleasant!
In any case, if you export a .ter file into OpenSim, anything lower than zero will be set to zero, so with the default setting anything lower than -20m in Leveller will be lost. I prefer to use -18m as the bottom height for a "default region" in Leveller, as it gives me some leeway in using the Perlin filter to make it bumpier. Things are different if you are using a water level higher than 20 in Opensim. If you have that set to 40, but are still using zero as the water level in Leveller (good practise), then you'd need to enter 40 for height adjustment in the File > Export tileset dialog instead of the default of 20. However, this also means that you can go down to -40m (or -38 to play safe) in Leveller when creating the sea floor.
Well assume that both examples are for default water height regions in Opensimulator. The first thing we can do is create a set of contour shapes around the land terrain. Here's one version of this for St Helena:
I haven't been too fussed about accuracy here with heights. The map for St Helena does show some undersea gradients, but according to the legend they go down to -3000m. Even adjusting for scaling, that would still be -162.15m, far too low for our purposes! Instead, this should give use a receding ocean floor. The next step is selecting only the ocean.We do this by using Selection > Select Elevations and using 0 and 400 for the elevation values. This selects everything above the water level. Then we use Selection > Invert Selection (or Ctrl + I). Everything that isn't the island is now selected:
Use Shapes > Heightfield from Points and we get the following:
As you can see only the selected area's been affected. The land remains untouched. Maybe we don't want an perfectly smooth ocean floor however. We use Filter > M-R > Perlin Noise and enter the following in the dialog box that pops up:
The How to Draw setting of Add means that the noise generated (in + and - height values) will be added to the existing height value. You could also try Average for a gentler result. Select OK, and we get this:
Here's a closeup of that:
Looks good. Save that document! We'll use the same process for Rottnest as well. Here's the contours:
And here's the finished result:
The Finished TerrainsYou can now export the St Helena and Rottnest documents using File > Export tilesets as shown in Part 2, in whatever combination of tiles you want. Here's how St. Helena looks exported to a grid of 1×1 of 1024m², on the map, from a distance, and compared to an avatar:
And here's how Rottnest looks being exported to a 4×2 grid of 256m², from a distance and with an avatar: