DEM - How to generate EE 2 maps with GDAL

Modding, Map Editor, IES Scripting and Other Tutorials
Post Reply
User avatar
Loewenherz
Posts: 244
Joined: 23 Sep 2017, 17:26
Has thanked: 7 times
Been thanked: 21 times

DEM - How to generate EE 2 maps with GDAL

Post by Loewenherz »

Thanks to: Schwarzer Reiter
https://ee.heavengames.com/cgi-bin/foru ... =17#post18



How to generate EE 2 maps with GDAL:

First we need to install Python and GDAL. An easy to follow guide for this can be found here:
https://sandbox.idre.ucla.edu/sandbox/t ... or-windows

Once installed, we can proceed to acquire the elevation data from which we'll generate the maps. Go to:
https://maps.ngdc.noaa.gov/viewers/grid ... index.html

Select ETOPO1 (bedrock) as data set. Select the area which you want to use for your map with the rectangle tool. You can optimise your selection by altering the coordinates in the Area of Interest field. Once satisfied with your selection download the data. You'll receive a file called exportImage.
Feel free to rename it to something more fitting, e.g. europemap. Just make sure to not use any spaces in the name. Add the file extension .tif to the file. Our example file would thus be europemap.tif. Take note of the directory where the file is located, e.g. your downloads folder.

Open now the windows command line by going to the Start Menu -> Run ->Type in cmd and hit Enter.
Type in cd followed by the directory where the .tif file is located, e.g. your download folder. Thus you should type:


cd C:\Users\User\Downloads

and hit Enter. We're now in the directory with the .tif file. Now type:

gdal_translate europemap.tif europemap.bil


and hit Enter.

A bunch of different files will be generated in the folder. Locate the file with the .bil extension, e.g. europemap.bil. Copy and paste it into your Elevation Maps folder, e.g. at
C:\Users\EE2Player\Documents\Empire Earth II\import

Change the file extension from .bil to .bin

Now create a new file in the Elevation Maps folder and give it the same name that your .bin file has, e.g. europemap.fmt. Paste this Text file now in your EE2 import Folder.

Code: Select all

input_eqv
begin name_equiv
	$minimum_value min__value
	$maximum_value max__value
end name_equiv
begin constant
	data_byte_order text little_endian
	file_title text My%Selection
end constant

ASCII_input_file_header_separate_varied	"selection header"
create_format 0 0 text 0

binary_input_data	"PC binary::elev_m"
elev_m 1 2 ARRAY["lat" 45.000000 to 35.000000 by 0.00833333333]["lon" -8.000000 to 0.000000 by 0.00833333333] OF int16 0
Now create a second text file which is now called europemap.hdr. In the generated files from GDAL is a own .hdr file. Open this file with Notepad and copy paste the following values:
BYTEORDER I
LAYOUT BIL
NROWS 2308
NCOLS 6889

NBANDS 1
NBITS 16
BANDROWBYTES 13778
TOTALROWBYTES 13778
PIXELTYPE SIGNEDINT
ULXMAP -123.983336665687
ULYMAP 55.6500018082917
XDIM 0.0166666686268745
YDIM 0.0166666686268745
... and put there in the .hdr file for Empire Earth 2.
file_title = europemap.hdr
data_type = raster
grid_cell_registration = center
map_projection = Lat/Lon
left_map_x = -123.983336665687
right_map_x = 55.6500018082917
upper_map_y = 0.0166666686268745
lower_map_y = 0.0166666686268745

number_of_rows = 1846
number_of_columns = 3401

grid_size = 0.00833333333
elev_m_unit = meters
min__value = -30
max__value = 4984
elev_m_min = -30
elev_m_max = 4984
elev_m_missing_flag = -500
number_of_display_colors = 256
data_value_unit = elev_m
data_byte_order = little_endian
If everything was done correctly you should now be able to generate a map in EE2's map editor from the .bin file we created. Have Fun. :D
At least here is a example file:
europe.zip
(20.02 MiB) Downloaded 213 times
Last edited by Loewenherz on 28 Dec 2020, 01:12, edited 1 time in total.
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160
These users thanked the author Loewenherz for the post:
Dr.MonaLisa

User avatar
Gonzalo
Posts: 336
Joined: 24 Aug 2018, 08:56
Been thanked: 3 times

Re: DEM - How to generate EE 2 maps with GDAL

Post by Gonzalo »

Good job! Congratulations!!
User avatar
Loewenherz
Posts: 244
Joined: 23 Sep 2017, 17:26
Has thanked: 7 times
Been thanked: 21 times

Re: DEM - How to generate EE 2 maps with GDAL

Post by Loewenherz »

It works to create own Pics for EE2 import. Just create a own picture and add the size of the pic in the .hdr file. I personally use this import values.
Highland.png
Highland.png (10.19 KiB) Viewed 6654 times
value.jpg
value.jpg (11.72 KiB) Viewed 6654 times
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160
Chandragupta Mourya
Posts: 3
Joined: 20 Oct 2023, 19:11

Re: DEM - How to generate EE 2 maps with GDAL

Post by Chandragupta Mourya »

I followed everything as mentioned but getting "unable to load dem data" error. All fmt, hdr and bin files are there.

india.hdr:

india.fmt:

What am I doing wrong?
User avatar
Dr.MonaLisa
High Representative
Posts: 8697
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 49 times
Been thanked: 108 times

Re: DEM - How to generate EE 2 maps with GDAL

Post by Dr.MonaLisa »

How did you generate these files?
left_map_x = 65.0083333333333
right_map_x = 36.9916666666667
upper_map_y = 0.0166666666666667
lower_map_y = 0.0166666666666667
This looks very weird, especially, when the Europe DEM has pretty nice coordinates:
left_map_x = -15.00000000000
right_map_x = 35.00000000000
upper_map_y = 60.00000000000
lower_map_y = 35.00000000000
But I'm just guessing. I never created any DEM myself.

Added after 2 minutes 2 seconds:
Also which GDAL version you used? The newest available one, or from that link on eeheaven?
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
Chandragupta Mourya
Posts: 3
Joined: 20 Oct 2023, 19:11

Re: DEM - How to generate EE 2 maps with GDAL

Post by Chandragupta Mourya »

Dr.MonaLisa wrote: 25 Oct 2023, 20:35 How did you generate these files?
left_map_x = 65.0083333333333
right_map_x = 36.9916666666667
upper_map_y = 0.0166666666666667
lower_map_y = 0.0166666666666667
This looks very weird, especially, when the Europe DEM has pretty nice coordinates:
left_map_x = -15.00000000000
right_map_x = 35.00000000000
upper_map_y = 60.00000000000
lower_map_y = 35.00000000000
But I'm just guessing. I never created any DEM myself.

Added after 2 minutes 2 seconds:
Also which GDAL version you used? The newest available one, or from that link on eeheaven?
I got it from the generated hdr file via gdal. I am using lates gdal version
User avatar
Dr.MonaLisa
High Representative
Posts: 8697
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 49 times
Been thanked: 108 times

Re: DEM - How to generate EE 2 maps with GDAL

Post by Dr.MonaLisa »

Where did you download the latest gdal version? I was trying to use some anaconda to install it, but it's so much stuff to do for such a little thing.
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
Chandragupta Mourya
Posts: 3
Joined: 20 Oct 2023, 19:11

Re: DEM - How to generate EE 2 maps with GDAL

Post by Chandragupta Mourya »

Dr.MonaLisa wrote: 27 Oct 2023, 09:36 Where did you download the latest gdal version? I was trying to use some anaconda to install it, but it's so much stuff to do for such a little thing.
https://www.gisinternals.com/release.php I downloaded it from here. Everything as said in the original tutorial.
User avatar
Loewenherz
Posts: 244
Joined: 23 Sep 2017, 17:26
Has thanked: 7 times
Been thanked: 21 times

Re: DEM - How to generate EE 2 maps with GDAL

Post by Loewenherz »

Just to answer the question. Unfortunately, loading DEMs does not work 100% with this programme. But at least 3 colours are converted to a certain height, so that you can use it as a basis for creating a map. It is advisable to improve the map by hand anyway.

viewtopic.php?p=26228#p26228

I have given some tips here. Otherwise, I simply put the generated data into an original file from an existing EE2 DEM file.
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160
Post Reply

Return to “Tutorials”