Giter Club home page Giter Club logo

world2minetest's Introduction

See below for screenshots


world2minetest is a tool to generate Minetest worlds based on publicly available real-world geodata. It was inspired by tools such as geo-mapgen.

Currently, the following geodata sources are supported. Heightmaps and .dxf CAD files must use the EPSG:25832 coordinate system.

Installation

  1. Copy this repo's content to your computer, e.g. by cloning:
    git clone https://github.com/FlorianRaediker/world2minetest.git
    
  2. Install the required Python modules:
    pip3 install -r requirements.txt
    

How to use

Generating a Minetest world consists of the following 4 steps. At least one of steps 1-3 is required.

  1. Generate a heightmap.
  2. Use OpenStreetMap data to add details.
  3. Add decoration (trees, bushes) using .dxf data.
  4. Create a map.dat file that can be read by world2minetest Mod for Minetest.

Generating a heightmap

A heightmap can be generated using the parse_heightmap_xyz.py script (see python3 parse_heightmap_xyz.py -h for details). First, download ASCII XYZ files and save them to the data_sources/ directory.

For Hanover (Germany), you can use this link.

Then, run parse_heightmap_xyz.py with any files you want to convert into a heightmap:

$ python3 parse_heightmap_xyz.py data_sources/path/to/file1.xyz data_sources/path/to/file2.xyz ...

This will create a new file parsed_data/heightmap.dat.

Use OpenStreetMap data

Select data using the Overpass API. Here is an example query:

[out:json][timeout:25][bbox:{{bbox}}];
(
   way;
   node;
);
out body;
>;
out skel qt;

Copy the JSON data from the "Data" tab into a new file data_sources/osm.json. Then, parse this data using parse_features_osm.py (see python3 parse_features_osm.py -h for details).

$ python3 parse_features_osm.py data_sources/osm.json

This will create a new file parsed_data/features_osm.json.

Add decoration from .dxf files

For geodata saved in .dxf files, parse_features_dxf.py can be used (see python3 parse_features_dxf.py -h for details). Currently, only trees and bushes are supported.

First, download .dxf files and save them to the data_sources/ directory.

For Hanover (Germany), you can use this link.

Then, run parse_features_dxf.py with any files you want to use. For each decoration, you will want to specify a query for ezdxf to get all entities representing that decoration. Currently, decorations tree, leaf_tree, conifer, and bush are available. Example command (for Hanover's data):

$ python3 parse_features_dxf.py data_sources/path/to/file1.dxf data_sources/path/to/file2.dxf ... \
    --query "*[layer=='Eingemessene Bäume' & name=='S220.40']" "tree" \
    --query "*[layer=='Nutzung_ Bewuchs_ Boden' & name=='S220.41']" "leaf_tree" \
    --query "*[layer=='Nutzung_ Bewuchs_ Boden' & name=='S220.43']" "conifer" \
    --query "*[layer=='Nutzung_ Bewuchs_ Boden' & name=='S220.46']" "bush"

This will create a new file parsed_data/features_dxf.json.

Detailed buildings with CityGML/CityJSON

CityJSON containing buildings can be used instead of buildings data from OpenStreetMap, for a higher level of detail.

If you have CityGML files, these need to be converted to CityJSON first. This can be done with citygml-tools:

$ ./citygml-tools to-cityjson --pretty-print data_sources/path/to/directory/with/citygml/files/

To obtain CityGML files for Hanover (Germany), you can use this link.

Run parse_cityjson.py with any files you want to use:

$ python3 parse_cityjson.py data_sources/path/to/file1.json data_sources/path/to/file2.json ...

This will create a new file parsed_data/buildings_cityjson.dat.

Putting it all together – creating map.dat

See python3 generate_map.py -h for details. Example usage:

$ python3 generate_map.py \
    --heightmap=parsed_data/heightmap.dat \
    --features=parsed_data/features_osm.json \
    --features=parsed_data/features_dxf.json \
    --buildings=parsed_data/buildings_cityjson.dat

This will save a file map.dat to the world2minetest folder, which contains the Mod for Minetest. Copy this folder to your Minetest installation's mods/ directory (or create a symlink for convenience).
To generate the map into a world, create a new world in Minetest and, before playing it for the first time, activate the world2minetest Mod.

Screenshots

License

world2minetest - Generate Minetest worlds based on real-world geodata
Copyright (C) 2021-2022 Florian Rädiker

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see https://www.gnu.org/licenses/.

world2minetest's People

Contributors

fyrk avatar nogajun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

holgerm

world2minetest's Issues

Map generation fails with TypeError

When loading a heightmap file with python3 generate_map.py --heightmap=parsed_data/heightmap.dat , I'm getting this error:

from 706000,5706000 to 708000,5708000 (size: 2001,2001) Traceback (most recent call last): File "/home/user/world2minetest/generate_map.py", line 122, in <module> if not (min_x <= args.offsetx <= max_x and min_y <= args.offsetz <= max_y): TypeError: '<=' not supported between instances of 'int' and 'NoneType'

DGM data has been taken from here: https://www.lvermgeo.sachsen-anhalt.de/de/dgm2.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.