I had an itch to create a real world map in Minecraft, but sadly I couldn't find any tools available to import heightmaps. Now I'm really quite a novice at programming, but luckily I know a bit of Python. And extra lucky! MCEdit was written in Python! That means I can easily borrow code!
Well, I somehow managed to write a script that can import height maps and texture maps and turn it into a terrain.
To run this script you need Python 2.7 or up (not Python 3.1 or 3.2), numpy, pypng and MCEdit's source. The full, boring details of its usage are in the Readme. I'm not too clear about whether redistributing other people's code is allowed or not, so I won't do it here.
Allow me to demonstrate its functions.
For this demonstration, I will be using a small map of part of the central Mediterranean.
With the script, the heightmap will define the elevation and the texture map will define the terrain type.
With slightly modified basic functions (to account for the differences in colour of real world terrain and Minecraft terrain)
You can define custom colour to terrain type mapping. So you can have stuff like lava seas with snow covered diamond blocks.
But wait! It is not simply limited to that! You can define the terrain block type above and below ground without limits! Here I changed the grass type to rainbow coloured wool, and dirt type to saplings with glass several blocks overhead.
You could potentially use up to 16 million different terrain types. Of course this will make the script run even slower than normal.
The script finds the shortest distance in CIELAB colour space to determine the terrain type for each pixel. This can be easily adapted to create images in Minecraft.
For example, I can turn this random image from google
into
Oh yeah! What about that world map?
Behold!
Big versions of the flat map and the Isometric map. Still JPEG unfortunately, unless you feel like downloading an 80MB image.
Yeah I noticed that the unexplored chunks look unlit in the map. I have no idea why that happens. Edited chunks also take longer than usual to load. Sometimes trees spawn out of nowhere. I also think I forgot to add in a line for snow, so the bits that look like snow are probably bare rock.
I won't be uploading the save to that btw. It's 200MB! :tongue.gif: It's from a 5400x2700 image from NASA and it's the small one :tongue.gif: That comes up to about 58000 chunks and several hours of processing time.
I suddenly realized I forgot to change the grass colour from the NASA one to the Minecraft one. Because grass is now grey in the texture file you see. Don't worry I just fixed it.
Quote from NetBlitzer »
Very, very nice. I'm gonna have to go get the large map and use it XD. We'll see how many chunks that creates.
I wouldn't recommend that :tongue.gif: At some point the script will try to eat up all your memory and... well actually I don't really know what will happen then.
EDIT: You could do it bit by bit. You can chop the image up into smaller ones with sizes in multiples of 16, and use different origin chunks for each image to stitch them together.
Quote from msmit71 »
Wow that is really cool! I doubt I will be able to run it on Mac 10.5.8 though...
I'm not familiar with macs, but if you can install python on macs, you can run this script, because it's the source you see.
Actually I confess I haven't the foggiest idea how to compile code and make exes. The Python tutorial didn't mention it at all.
Insaaane! Congratulations for this! I was soo looking for a program like this! Thanks man :biggrin.gif:
You sure you can't upload the world map though? Pretty please :3
EDIT: The readme instructions aren't clear... where is mclevel.py located??? I can't find it anywhere.
Hmm. Did you get the MCEdit source? mclevel.py is one of the main modules for mcedit. You'll need the source files, not the exe. If you go here, you can get it. Unfortunately, I'm not skillful enough to make my own independent program, so you'll have to jump through a few hoops to make it work.
My world map is missing snow unfortunately, anyway you may want to use custom terrain definitions depending on how you want your map to look. You may want to try it out on a smaller map first, because generation takes pretty long. The script seems to process 100 chunks in roughly 8 seconds on my laptop, and the mcedit lighting recalculation routine takes about as long as the chunk modification.
Actually it was quite a pain to create a composite heightmap for the land elevation and sea depth, so I'll put it up to save you the effort. Here. It's definitely not perfect, there are a lot of black specks around the various coastlines and stuff like that. I blame anti-aliasing and jpeg compression.
So, I gotta download the source files and put the Heightmapper files on that same directory. And I also gotta place the map I want to turn into a world (I cropped a part of that big one) in there. What I don't understand is:
-Where to place the MCE source folder or files
-What is the RGB texture map
You've got it mostly right.
You can simply place the MCE source folder anywhere you like. As for the RGB texture map, it's basically a full colour map of the same area you are trying to import. The colours will define what kind of terrain will be produced. I added that feature because I thought that it would be pretty useless if a heightmap importer just created a terrain made out of dirt.
The reason why I said RGB was that the script assumes that the colours in the colour file are in RGB format. Now since I'm using an external python module to import png files, I'm not sure what kind of data it will spit out if you use a file that is formatted with some other colour model. It might convert it to RGB or it might not, so it is better to be safe than sorry.
I assume you have a satellite photo map as well as the height map? You can use a image of the colour map that is the same size as the height map and the script will try to match the colours in the picture to Minecraft block colours. By default I only enabled the natural block types such as grass, dirt, stone etc. although the colour information for the other blocks is also included.
I suggest you modify the file controlling the colour to block type mapping (colourinfo.txt) because the colour of real world terrain poorly matches with Minecraft's cartoony colours.
For example, in the NASA image I used, grassy areas of the world tended to be a dark yellowish green, which is turns out to be closer to the colour of dirt than grass in the colour space. This leads to a world made out of dirt. It seems that brown is a pretty average colour.
To fix this, I used a colour picker to determine the RGB value of the dark yellowish green, and changed the colour of the entry defining GRASS in the colourinfo file to better match it. That way when the script sees a pixel that is dark yellowish green in the colour file, the GRASS entry will be the one closest to it instead of dirt.
I'm having problems with the fact that Numpy requires 2.6... Also I found a world map image that is 15306 by 7653. I'll try that later if I get this working. And when you're system runs out of memory (RAM), it starts using your hard disk (ROM). So I don't think I'll have to worry. Might take a few hours though.
EDIT: Never mind, found the download.
I'm having problems with the fact that Numpy requires 2.6... Also I found a world map image that is 15306 by 7653. I'll try that later if I get this working. And when you're system runs out of memory (RAM), it starts using your hard disk (ROM). So I don't think I'll have to worry. Might take a few hours though.
EDIT: Never mind, found the download.
I had an itch to create a real world map in Minecraft, but sadly I couldn't find any tools available to import heightmaps. Now I'm really quite a novice at programming, but luckily I know a bit of Python. And extra lucky! MCEdit was written in Python! That means I can easily borrow code!
Well, I somehow managed to write a script that can import height maps and texture maps and turn it into a terrain.
Here it is!
Brief Instructions and preview
To run this script you need Python 2.7 or up (not Python 3.1 or 3.2), numpy, pypng and MCEdit's source. The full, boring details of its usage are in the Readme. I'm not too clear about whether redistributing other people's code is allowed or not, so I won't do it here.
Allow me to demonstrate its functions.
For this demonstration, I will be using a small map of part of the central Mediterranean.
With the script, the heightmap will define the elevation and the texture map will define the terrain type.
With slightly modified basic functions (to account for the differences in colour of real world terrain and Minecraft terrain)
You can define custom colour to terrain type mapping. So you can have stuff like lava seas with snow covered diamond blocks.
But wait! It is not simply limited to that! You can define the terrain block type above and below ground without limits! Here I changed the grass type to rainbow coloured wool, and dirt type to saplings with glass several blocks overhead.
You could potentially use up to 16 million different terrain types. Of course this will make the script run even slower than normal.
The script finds the shortest distance in CIELAB colour space to determine the terrain type for each pixel. This can be easily adapted to create images in Minecraft.
For example, I can turn this random image from google
into
Oh yeah! What about that world map?
Behold!
Big versions of the flat map and the Isometric map. Still JPEG unfortunately, unless you feel like downloading an 80MB image.
Yeah I noticed that the unexplored chunks look unlit in the map. I have no idea why that happens. Edited chunks also take longer than usual to load. Sometimes trees spawn out of nowhere. I also think I forgot to add in a line for snow, so the bits that look like snow are probably bare rock.
I won't be uploading the save to that btw. It's 200MB! :tongue.gif: It's from a 5400x2700 image from NASA and it's the small one :tongue.gif: That comes up to about 58000 chunks and several hours of processing time.
Credit to:
codewarrior for MCEdit
Ores not included.
I suddenly realized I forgot to change the grass colour from the NASA one to the Minecraft one. Because grass is now grey in the texture file you see. Don't worry I just fixed it.
I wouldn't recommend that :tongue.gif: At some point the script will try to eat up all your memory and... well actually I don't really know what will happen then.
EDIT: You could do it bit by bit. You can chop the image up into smaller ones with sizes in multiples of 16, and use different origin chunks for each image to stitch them together.
I'm not familiar with macs, but if you can install python on macs, you can run this script, because it's the source you see.
Actually I confess I haven't the foggiest idea how to compile code and make exes. The Python tutorial didn't mention it at all.
Hmm. Did you get the MCEdit source? mclevel.py is one of the main modules for mcedit. You'll need the source files, not the exe. If you go here, you can get it. Unfortunately, I'm not skillful enough to make my own independent program, so you'll have to jump through a few hoops to make it work.
My world map is missing snow unfortunately, anyway you may want to use custom terrain definitions depending on how you want your map to look. You may want to try it out on a smaller map first, because generation takes pretty long. The script seems to process 100 chunks in roughly 8 seconds on my laptop, and the mcedit lighting recalculation routine takes about as long as the chunk modification.
Actually it was quite a pain to create a composite heightmap for the land elevation and sea depth, so I'll put it up to save you the effort. Here. It's definitely not perfect, there are a lot of black specks around the various coastlines and stuff like that. I blame anti-aliasing and jpeg compression.
The original images were from NASA's blue marble webpage.
You've got it mostly right.
You can simply place the MCE source folder anywhere you like. As for the RGB texture map, it's basically a full colour map of the same area you are trying to import. The colours will define what kind of terrain will be produced. I added that feature because I thought that it would be pretty useless if a heightmap importer just created a terrain made out of dirt.
The reason why I said RGB was that the script assumes that the colours in the colour file are in RGB format. Now since I'm using an external python module to import png files, I'm not sure what kind of data it will spit out if you use a file that is formatted with some other colour model. It might convert it to RGB or it might not, so it is better to be safe than sorry.
I assume you have a satellite photo map as well as the height map? You can use a image of the colour map that is the same size as the height map and the script will try to match the colours in the picture to Minecraft block colours. By default I only enabled the natural block types such as grass, dirt, stone etc. although the colour information for the other blocks is also included.
I suggest you modify the file controlling the colour to block type mapping (colourinfo.txt) because the colour of real world terrain poorly matches with Minecraft's cartoony colours.
For example, in the NASA image I used, grassy areas of the world tended to be a dark yellowish green, which is turns out to be closer to the colour of dirt than grass in the colour space. This leads to a world made out of dirt. It seems that brown is a pretty average colour.
To fix this, I used a colour picker to determine the RGB value of the dark yellowish green, and changed the colour of the entry defining GRASS in the colourinfo file to better match it. That way when the script sees a pixel that is dark yellowish green in the colour file, the GRASS entry will be the one closest to it instead of dirt.
EDIT: Never mind, found the download.
Well for anyone else who can't find it, I used an unofficial build from here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Can someone tell me how to make this work?
A bug. The error appears when the script tries to draw a block above the max world height. I fixed it so that the height is capped properly.
Also, maybe your greyscale image might have a higher bitdepth. Well, I fixed it so that it doesn't matter anymore.
You deservae a dimond! :biggrin.gif: