Author Topic: Automatic terrain generation from geographical data (a tool I created)  (Read 30704 times)

Offline artik

  • Silver Member
  • ****
  • Posts: 1909
      • Blog
Hello,

Back in AH1 days there was a tool called MapMaker that used both GTOPO30 Digital Elevation Map (DEM) and the ground coverage types from USCG to create realistic maps.

Unfortunately it is not relevant for AH2 any more also the database used had quite a low resolution. Currently designers set different ground types according to altitude with both not correct and it very problematic for areas with large ground type differences, like dessert, rivers, forests etc.

I had written a new tool called "makeahmap" that creates elevation files, water file and ground type files using more up to date database: GlobCover.

It has much higher resolution and allows to setup fine details of the ground.

For example, this is a color coded distribution of the ground coverage I had used for 512x512 miles map:

http://cppcms.com/pics/cov.png

It has very fine grained details like Nile, Suez Channel, exact position of Dead sea and Sea of Galilee boundaries that are impossible to derive from the altitudes alone (dead sea is -1200 feet below the surface of the sea). You can see the rich agricultural areas of Delta Nile and desert areas.

Now I combined it with the elevation database and could create the map.

Note it is very initial version and probably buggy:

Download from: http://cppcms.com/files/makeahmap.zip

You will need to download the GlobCover database file and DEM files (links in README)

Unzip, read README.txt, edit config.ini to configure the setup and run to create gndtype.bmp, mapname.elv and water(d/c).bmp

Notes:

- it does not have GUI, you rather edit config.ini and double-click on the exe. It should be straight forward to use. (I would not implement GUI at this point)
- You need the coordinates of the area you want to create, it is very useful to work with google maps to configure them.


Sources are included. User input is more than welcome.

The software licensed under MIT software license.


« Last Edit: October 16, 2013, 09:14:37 AM by artik »
Artik, 101 "Red" Squadron, Israel

Offline USRanger

  • AvA Staff Member
  • Plutonium Member
  • *******
  • Posts: 10325
      • BoP Home
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #1 on: October 17, 2013, 02:02:18 AM »
Very cool.  I'll check it out. :aok

 :salute
Axis vs Allies Staff Member
☩ JG11 Sonderstaffel ☩
Flying 'Black[Death] 10' ☩JG11☩

Only the Proud, Only the Strong Ne Desit Virtus

Offline ghostdancer

  • Aces High CM Staff
  • Platinum Member
  • ******
  • Posts: 7562
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #2 on: October 17, 2013, 11:32:52 AM »
Will take a look at this later in the week. Thanks for the effort.
X.O. 29th TFT, "We Move Mountains"
CM Terrain Team

Offline bbosen

  • Silver Member
  • ****
  • Posts: 963
      • AskMisterWizard.com
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #3 on: October 17, 2013, 12:49:17 PM »
Wow Artic! This sounds WONDERFUL. I will look for a time soon to exercise it. Thanks!
 :salute

Offline artik

  • Silver Member
  • ****
  • Posts: 1909
      • Blog
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #4 on: October 17, 2013, 04:39:46 PM »
Some update,

I'm working on the support of GSHHG database to support more accurate shore lines.

For a map of 512x512 miles:

Elevations: map.elv is 1024x1024: 1/2 a mile resolution GTOPO30 DEM is more than file.
Ground cover: gndtype.bmp is 4096x4096: ~200m resolution - GlobCover is fine - as approximately same resolution .
Water: waterd.bmp 16384x16384: ~50m resolution - the GlobCover is not good enough apparently the coast lines look too square. One option is to run some filter (like low pass Gaussian blur + threshold. Other option I'm working is to use shoreline database.

I'm working on support of the GSHHG database that keeps the shore lines in vector format to create waterd.bmp raster such that the data would be much more accurate and smooth - so the shorelines, also it would allow to distinguish between ocean/sea and lakes and rivers.

(It works but need some optimization to be done)

To be continued...
Artik, 101 "Red" Squadron, Israel

Offline 715

  • Silver Member
  • ****
  • Posts: 1835
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #5 on: October 17, 2013, 09:50:54 PM »
I'm impressed! 

I tried looking at the shoreline data ESRI shapefile format as a possible way to generate high res water data, but the format was so obtuse, I immediately gave up.  The generation of those vector data water files was based on bitmap DEM file analysis; it's a shame they didn't spit out a pixel water binary file to go along with the matching DEM file.  Since it's a single bit (water or ground) it would have added very little to the zipped file size.

Offline artik

  • Silver Member
  • ****
  • Posts: 1909
      • Blog
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #6 on: October 18, 2013, 12:42:59 AM »
I'm using GSHHG binary format... It is way simpler to read. The only problem you need to solve is to convert polygon to bitmap at scale of Earth efficiently  :D
Artik, 101 "Red" Squadron, Israel

Offline 715

  • Silver Member
  • ****
  • Posts: 1835
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #7 on: October 18, 2013, 02:14:52 AM »
artik: is the GlobCover data really just one huge TIF file covering the entire Earth (GLOBCOVER_L4_200901_200912_V2 .3.tif)?  How do you read that?  My PhotoShop elements chokes on it.  Or is GeoTiff a different thing from .tif?

Offline artik

  • Silver Member
  • ****
  • Posts: 1909
      • Blog
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #8 on: October 18, 2013, 07:46:25 AM »
artik: is the GlobCover data really just one huge TIF file covering the entire Earth (GLOBCOVER_L4_200901_200912_V2 .3.tif)?  How do you read that?  My PhotoShop elements chokes on it.  Or is GeoTiff a different thing from .tif?

Don't open this file on PS. Most of editors and other tools fail frequently even on waterd.bmp.

I read it using libtiff, row by row (There is an API for that) and select specific parts I need using the code.

For same reason I don't load all files in DEM, I load a single row in a time (about 20-80 mb depending on latitude/map-scale/dimension).

Most of tools just can't handle such huge amount of data.
Artik, 101 "Red" Squadron, Israel

Offline ghostdancer

  • Aces High CM Staff
  • Platinum Member
  • ******
  • Posts: 7562
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #9 on: October 18, 2013, 09:18:04 PM »
Shorelines are a pain. As you point out the various formats don't give you really good / exact shoreline detail. Basically you have two manual ways to deal with this at the moment.


1) Go into the Terrain Editor and clean them up by hand making them look more organic and less blocky. Problem here is you still don't get exact shorelines but they do look natural and most players won't complain about them. Especially if the terrain is not a historic / real world terrain.

2) Or you can go into waterd.bmp and work on the shore lines directly in a program like Photoshop. If you do that you can very detail shorelines by going into say google maps zoom down to the say the 1 mile, 2 mile or 5 (depending on your scale) mile take a screen shot, paste as a new layer in photshop over your existing land created by the DEM and then use this as a stencil to trace and clean up the shore lines.

Yes this is VERY tedious and horrendously manual method but it has given me good results on several terrains on creating exacting shorelines for terrains. Of course a drawback is that the shorelines are based on current info not 1930s-1940s info.


So a shoreline database would be quite helpful.
X.O. 29th TFT, "We Move Mountains"
CM Terrain Team

Offline artik

  • Silver Member
  • ****
  • Posts: 1909
      • Blog
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #10 on: October 19, 2013, 03:23:36 AM »
Quote
Shorelines are a pain. As you point out the various formats don't give you really good / exact shoreline detail.

Ok some progress report..

There is a wated.bmp I created automatically using shoreline and river database.

http://cppcms.com/files/waterd.zip

It is quite amazing, there is Nile, there is Jornan river, amazing Suez channel, take a look on the North Egypt shore...

And it is smooth...

I hadn't done any gradients yet, it is all 0 or 255, but it is work in progress.

Quote
Basically you have two manual ways to deal with this at the moment.

I'm too lazy to do it manually :D ... So I write a program for it.
Artik, 101 "Red" Squadron, Israel

Offline Bruv119

  • Aces High CM Staff
  • Plutonium Member
  • *******
  • Posts: 15670
      • http://www.thefewsquadron.co.uk
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #11 on: October 19, 2013, 07:23:19 AM »
artik you are the man.
The Few ***
F.P.H

Offline ghostdancer

  • Aces High CM Staff
  • Platinum Member
  • ******
  • Posts: 7562
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #12 on: October 19, 2013, 07:45:55 AM »
Quote
I hadn't done any gradients yet, it is all 0 or 255, but it is work in progress.

Remember that gradients in the waterd.bmp file does not create land. It creates water depth which allows textures painted by gndtype.bmp to show through the water to the players flying above. Most people will be happy with what you have done here and not care about water depth.

Going to go load up your waterd.bmp file in the editor and take a look.

I would say I am to lazy to but its more a case of not having a program to do it for me. ;)


« Last Edit: October 19, 2013, 08:06:51 AM by ghostdancer »
X.O. 29th TFT, "We Move Mountains"
CM Terrain Team

Offline ghostdancer

  • Aces High CM Staff
  • Platinum Member
  • ******
  • Posts: 7562
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #13 on: October 19, 2013, 08:03:04 AM »
Very nice results and lots of rivers. Those might give you a head ache when you start working on elevation.

Oh quick question so does this program only handle a scale of 1:1 (1 game mile equals 1 real mile) or can handle differing scales say 1:1.5 (1 game mile equals 1.5 real miles) and so on? Some times for game play reasons designers you differing scales from 0.75:1 to 2:1.
« Last Edit: October 19, 2013, 08:06:07 AM by ghostdancer »
X.O. 29th TFT, "We Move Mountains"
CM Terrain Team

Offline artik

  • Silver Member
  • ****
  • Posts: 1909
      • Blog
Re: Automatic terrain generation from geographical data (a tool I created)
« Reply #14 on: October 19, 2013, 08:27:39 AM »
Quote
I would say I am to lazy to but its more a case of not having a program to do it for me.

I'll release the next version ASAP... Not need to wait but need some touches to made.

Quote
Oh quick question so does this program only handle a scale of 1:1 (1 game mile equals 1 real mile) or can handle differing scales say 1:1.5 (1 game mile equals 1.5 real miles) and so on? Some times for game play reasons designers you differing scales from 0.75:1 to 2:1.

Any scale you want, you give central point latitude and longitude, dimensions and scale - you get a data.
Artik, 101 "Red" Squadron, Israel