Skip to content

Custom terrain dataset guide

DavixDevelop edited this page May 2, 2024 · 32 revisions

Custom Terrain from Lidar data/Raster data

This guide is intended for those who wish to use the custom terrain feature for Terra++ and wish to use lidar/raster data as the data source. Before you continue, check if your country already has a guide here. Also, be sure to check out Advanced guide for larger areas to find out if it is suitable for your purposes.

Supported raster formats

Name Extension
GeoTIFF .tif
Erdas Imagine .img

Before you continue, take note that this guide is split into two parts. Follow the Part one (see below) if your dataset is in any other format than the supported raster formats (see above)

Preparing your dataset Generating/using your dataset
This guide teaches you how to prepare your dataset, if your dataset is in any other format than the supported raster formats (see above), for example, if you wish to use LiDAR data. The second part teaches you, how to generate/use the optimized dataset
Link to Part one Read bellow

NOTE: At the end of this guide you will create a generated dataset. If you plan on using the dataset for a multiplayer world, It's very recommended that you host the generated dataset separately, ex. on Amazon S3, VPS... When choosing a host, It's essential that it provides efficient storage space, but things like CPU or RAM specs don't matter.

Part two: Generating/using your dataset

A. QGIS preparation & QMetaTiles plugin

  • First, download and install the latest version of QGIS in OSGeo4W
  • After installing, open it
  • Navigate to Plugins/Manage And Install Plugins... in the toolbar
  • In the opened window click on All and search for QMetaTiles
  • Click on the result and install it
  • Close the window

B. Importing your dataset

Note: This assumes, your dataset is already in the GeoTIFF (.tif) format. If not, go here.

  • Next, navigate to Plugins/Python Console in the toolbar
  • In the opened bottom panel click on the Show Editor button (Script icon)
  • Using the Open Script... button open the loadraster_folder.py file in QGIS Python Console
  • Double click on OpenStreetMap in the left panel (Under 'XYZ Tiles' in the Browser panel [View/Panels/Browser])
  • Navigate to the file_directory line (line: 12)
  • Here replace the path with your path to the folder where your .tif files are located
  • If you want to import all files in the folder, including subfolders, set recursive (line: 13) to True, else continue
  • Save the changes using the Save button (Floppy disk icon)
  • Navigate to View/Panels/Log Messages in the toolbar
  • Now, run the script by clicking on the Run Script button (green play button)
  • It may lag a bit at the start and the end but let it run. Again, this can take a while
  • The script outputs the progress into the Log Messages panel
  • Once It's done QGIS will send you a notification

B.1 Visible rendered black parts on the imported dataset

If your imported dataset contains rendered black parts, meaning an elevation of −32768 meters, your dataset most likely doesn't have the correct NODATA or no NODATA value specified. To check it open OSGeo4W Shell, navigate to where your dataset is stored via cd <your_dataset_path>, and run gdalinfo <example_source_raster_file_fullname>. If the output doesn't contain the NODATA value entry or an incorrect value, run set_no_data_recursive.py on your dataset in QGIS Python Console, and rerun the loadraster_folder.py script.

C. Setting up the project

  • Select all your imported layers in the left and right-click on them
  • Navigate to Set CRS/Set Layer CRS...
  • In the opened window choose the same coordinate reference system your lidar/source dataset uses (ex. Slovenia 1996 / Slovene National Grid). If you have problems with this step, select the layer, go to Layers/Save as, set the CRS, save the file/files and repeat the C section.
  • Click OK
  • In the bottom right corner click the current project coordinate reference system (ex EPSG...)
  • In the opened windows search for EPSG:4326 (WGS 84)
  • Click on WGS 84 and click OK
  • Make sure the layers are in the right location over the map

D. Generating tiles

Finding out the zoom level

To find out the proper zoom level for your dataset first find out the latitude and the resolution (ex. 1 meter) of your dataset. For example, you can use the central latitude of your dataset. After you found it, open the SmylerBTE API - Zoom tool. Once it opens, fill in your resolution and latitude and press on Calculate. The tool will then tell you which zoom to choose. Once you press on OK in the popup, the table will have the preferred zooms highlighted, if you want to choose the zoom manually. Just remember, if you choose a lower zoom from the table the rendered dataset would be upscaled, but if you choose a higher zoom, it would be downscaled. For most instances, It's better to choose the zoom, which it's resolution is closer to your resolution.

Using the QMetaTiles plugin

  • Delete the OpenStreetMap layer
  • Navigate to Plugins/QMetaTiles/QMetaTiles
  • Set the Tileset name and choose the Output Directory (ex. Documents\Minecraft\CustomTerrain)
  • Select Full extent (Make sure the OpenStreetMap layer is deleted)
  • Set the Minimum and Maximum zoom to the zoom level you've found out in the above sub-step, just remember that a higher zoom level will use more disk space
  • Disable Metatiling
  • Set the Quality under Parameters to 100
  • Select Make lines appear less jagged at the expense of some drawing performance
  • Make sure that the format is set to PNG
  • Click OK
  • This will take quite a while depending on how large an area you have
  • Once It's finished you can close QGIS

E. Dataset bounds

If you already know your bounding box coordinates, and they are in the WGS 84 (EPSG:4326) coordinate system, you can skip this step. If they are not in the WGS 84 (EPSG:4326) coordinate system, skip to Converting the bounds to WGS 84 (EPSG:4326). Else continue with the guide.

Finding your dataset bounds

  • Note: If you only imported one file, you can simply right-click on the layer, click on Properties... and take note of the Extent under Information as seen on the image above. Then you can continue to the step below if the layer CRS isn't WGS 84 (EPSG:4326). If it is, you can continue to step F. There are two ways you can find the bounding box coordinates. You can either find the bottom left and top right layer, or you can create a virtual raster.

First method Second method
First find the leftmost layer. Right-click on the layer, and go to Properties.... Take note of minX on Extent under Information (as seen in the image above). Next, find the rightmost layer, and take note of maxX via Properties... again. Now find the topmost layer and take note of maxZ. Lastly, find the bottom-most layer and take note of minZ. Then you can continue to the step below if the layers CRS isn't WGS 84 (EPSG:4326). If it is, you can continue to step F. First, go to Raster/Miscellaneous/Build Virtual Raster.... Once the dialog opens, under Input layer, select all layers (as shown in the image). Once you've selected all layers, click on the back arrow. Next under Resolution select Highest and click on the Run button below. Once the process finishes, close the dialog by clicking on the Close button. Next, right-click on the newly created layer (Virtual) and click on Properties.... Lastly take note of minX, maxX, minZ, and maxZ on Extent under Information. Now you can continue to the step below if the Virtual layer CRS isn't WGS 84 (EPSG:4326). If it is, you can continue to step F.

Converting the bounds to WGS 84 (EPSG:4326)

  • First, navigate to the epsg.io page
  • Now search for your coordinate system (ex. Slovenia 1996 / Slovene National Grid)
  • Once you've opened the coordinate system page, click on Transform
  • First under Input coordinates, input minX in the X textbox and minZ in the Y textbox, as shown on the image above
  • Make sure that under Output coordinate system, It's set to EPSG:4326 WSG 84
  • Make sure that under Output coordinates, Format is set to dec
  • Then click on Transform and under Output coordinates take note of Longitude and Latitude. The Longitude becomes minX and Latitude becomes minZ.
  • Lastly, repeat the process for maxX and maxZ

F. Using your generated dataset

  • Download and install Terra++ from here or build it yourself from here

It's very essential that your heights folder doesn't contain the old default.json5 or any file with the json5 extension. If it does, you must also delete the .json file and set it up again, by following the steps below

**Note: If your .minecraft folder doesn't contain the terraplusplus folder, you must first create the world using, like mentioned here

Note: If you came from Advanced guide for larger areas and don't have any custom dataset defined, copy the heightsTemplate.json file in the output folder to .minecraft\terraplusplus\config\heights (ex. C:\Users\david\AppData\Roaming.minecraft\terraplusplus\config\heights) and rename it to heights.json.
If you have any custom dataset already defined in the heights.json folder, copy the entries in heightsTemplate.json to the existing heights.json file.
Otherwise, if you wish to manually set the heights config, use the info in the heightsTemplate.json file or the Log Messages and follow the steps below.

  • Download heights.json, and move it to .minecraft\terraplusplus\config\heights (ex. C:\Users\david\AppData\Roaming.minecraft\terraplusplus\config\heights)
  • Open heights.json in a text editor
  • As shown in the picture, in step 1, replace (path to dataset) with your path to your dataset, for example, C:/Users/david/Documents/Minecraft/CustomTerrain/Flats
  • Next to it, as shown in step 2, replace (zoom level) with the level of zoom, you rendered your dataset under
  • Then, as shown in step 3, also replace (zoom level) with the level of zoom, you rendered your dataset under
  • Finally, paste in the noted minX, minZ, maxX and maxZ (from step E) under bounds as shown in step 4. The coordinates must be in WGS 84 (EPSG:4326)
  • Save the file, open Minecraft, and load the save you've created or create a new world by selecting the World Type: Planet Earth, clicking on Customize, and choosing the Build The Earth preset
  • Once your world loads, navigate to your desired location using the /tpll command and it should load your custom terrain

Need help or have a question?

You can contact me on Discord, under davixdevelop#3914, or you can join us on our BTE Development Hub on Discord, and ask away under the #terraplusplus-support channel.