gaelysam / geo-mapgen

Minetest mod and Python script to generate a Minetest world from a GeoTIFF image
GNU Lesser General Public License v2.1
23 stars 4 forks source link
digital-elevation-model map-generator minetest minetest-mod python-script river-networks

Geo Mapgen

Geo Mapgen is a (still experimental) mod for Minetest that allows to generate map from digital elevation models like SRTM.

It is somewhat like realterrain but behaves differently: you need to run a separate Python file that transform the image into a database that is directly readable by Minetest. This solution was made to avoid running Lua libraries with Minetest (which is not recommended) or reading directly the image with the Lua API that is not made for that.

Grand Canyon

Generating a map

Using the latest development version of Minetest (0.5.0-dev) is highly recommended, especially if you enable land cover.

Finding data

This program doesn't come with pre-loaded geographical data, it only provides the tools to use them. You need to find your data on the Internet. All needs to be in an image format (usually GeoTIFF). The only mandatory data set is the topographical map, but you can also use additional maps for land cover or rivers.

Topographical data

You need topographical data, in the form of a Digital Elevation Model (DEM). It's an image that represents the terrain height for each point in a given area. There are several freely available DEMs, that differ in coverage, resolution, and quality.

I personally strongly recommand SRTM. It provides worldwide elevation tiles, that are not too big (6000² pixels, 1 px = 93 meters) and thus handy to work with, and are not projected.

Land cover data

Land cover support has been added last, this is something that has required much work, and unfortunately it still needs some work for the user to get it working.

To enable land cover, you need land cover data, in raster GeoTiff format. This is quite hard to find. A good reference for Europe is Corine Land Cover.

You also need to write a legend file, to decode the map. Geo Mapgen can't know which value matches which biome, and it has to be defined in a file (that I named .lct, for "Land Cover Table"). Its structure is the following:

1   urban
2   urban
3   industrial
4   industrial
5   industrial
6   industrial
7   rock
8   dirt
9   dirt
10  grass
11  dirt
12  fields
13  fields
14  fields
15  fields

Every line mean that one value in the data (for example 10) matches a particular land cover type recognized by Geo Mapgen (in this case "grass"). You need to find the legend of the map, and decide in which category every legend entry fits the most, and write the file. I've already written it for Corine Land Cover and MODIS, you can find these files in Land cover tables/. I can do it for other land cover maps if you kindly ask me ;)

List of biomes and land covers currectly supported by Geo Mapgen:

River maps

River maps are mostly for advanced GIS users that are able to make such images from vector hydrographic data. It should represent the river network: every non-zero value will be interpreted as a river.

Converting data

You must first convert the DEM image into a database, using the python script image_convert.py provided by this mod. You need a working Python 3 installation, with the following libraries:

Launch the script: go in geo-mapgen's directory, and run this:

./image_convert.py

You will see this interface: Interface

Set the parameters (they are referenced below), and press Proceed. The conversion can take a moment, please be patient. You can see what happens in the console. When it prints "Done.", you can start your Minetest world.

Complete list of parameters

I/O Files

Region

To define the coverage of your map, and the sampling.

You have 3 options:

WARNING: If you are using a very large image, make sure to resize the image so that your map is not too large (typically 15x15k pixels). Check with Calculate size. Otherwise, your computer may run out of memory.

Generic parameters

Land Cover

Land cover image: path to your land cover image.

Land cover legend file: path to legend file, see above in Land Cover Data section.

Rivers

Geo Mapgen can calculate automatically the positions of rivers with the elevation map, or load another image that will represent rivers.

Be aware that rivers calculation can be very slow (around 15 minutes for a 6000x6000 map).

Configuration file

A config file heightmap.dat.conf is generated in the world directory. It has the same syntax than minetest.conf, and currently supports the following parameters:

For example if you have generated a map with a resolution of 100 meters by pixel, and you set this in heightmap.dat.conf:

scale_x = 2
scale_y = 2
scale_z = 2
offset_x = -500
offset_y = 10
offset_z = 1000

Then geo mapgen will generate a map with 200 meters per node in each direction, with the upper left corner at (-500, 1000) and the sea level at 10.

Please note that this rescaling does not perform interpolation.

Additional information

Distributed under the GNU Lesser General Public License, version 2.1. Code by Gael-de-Sailly (Gaël C.)