Before using a map with ttMaps, make sure you have the right! Some publishers of paper maps prohibit you to scan them, and vendors of maps on CDROM impose very restrictive licenses, such as the ban on the use of maps with other software than that provided by the vendor.
The format that was chosen for ttMaps is the ECW format, developed by the company Er Mapper, recently acquired by ERDAS.. Why use such a choice? This format has many advantages for mapping applications:
It is a format chosen by the IGN to deliver maps and aerial photographs. It is therefore possible to directly use the files from IGN. See, for example, screenshots some of which were produced with samples of IGN maps.
Before you start converting the maps to ECW format, you must make sure they are calibrated (georeferenced), therefore you need to know:
In general, the datum and projection are shown in the legend text of paper maps. If you do not know the geographical extents, you must first calibrate the map. I will not explain in detail how to do this, because there are many programs available, such as:
The main tools are:
export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH
Here are three examples of using GDAL to convert the maps to the ECW format.
Some file formats, such as GeoTIFF, include georeferencing data. For example, download the Sample GeoTiff file. After unpacking the archive, you can use the gdalinfo command to display information about the file:
gdalinfo sample_geotiff.tif Coordinate System is: PROJCS["WGS 84 / UTM zone 10N", GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.2572235630016, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0], UNIT["degree",0.0174532925199433], AUTHORITY["EPSG","4326"]], PROJECTION["Transverse_Mercator"], PARAMETER["latitude_of_origin",0], PARAMETER["central_meridian",-123], PARAMETER["scale_factor",0.9996], PARAMETER["false_easting",500000], PARAMETER["false_northing",0], UNIT["metre",1, AUTHORITY["EPSG","9001"]], AUTHORITY["EPSG","32610"]] Origin = (563460.782789624412544,4180651.692221448291093) Pixel Size = (14.250000000000000,-14.250000000000000)
This information allows us to know the reference system (here WGS84) and the projection used (here, UTM Zone 10 North). Unfortunately, Er Mapper uses its own names to designate the reference systems and projections. Before making the conversion, you must find these names.
gdal_translate -of ECW -co "TARGET=90" -co "DATUM=WGS84" -co "PROJ=NUTM10" sample_geotiff.tif sample.ecwThe parameter TARGET=90 indicates that you wish to obtain a compression ratio of the image equal to 90% (Change the rate depending on the type of image). Note: Avoid using the same base name for input file and output file, otherwise you may encounter some problems with the current version of gdal_translate. To view the result, you can use for example ER Viewer or QGIS.
Some files, such as TIFF, JPG or PNG may be accompanied by a world file containing the geographical extents of the map. These files have respective extensions .TFW, .JGW and .PGW .
One example is the SCAN1000 map of IGN, which is freely available on the IGN site.
Download for example SCAN 1000 Corsica (Version Lambert II extended) and unzip the archive. The useful files are COR_0000.TIF (TIFF image) and COR_0000.TFW, which contains the coordinates and size of pixels. The gdalinfo command shows that this file uses a color palette:
Band 1 Block=1200x25 Type=Byte, ColorInterp=Palette Color Table (RGB with 256 entries)
The gdal_translate utility is not capable of converting a file based on a color palette to a file in 16 million of colors. Fortunately, a conversion utility (pct2rgb.py) comes with the GDAL package. You must therefore begin doing this conversion:
pct2rgb.py COR_0000.TIF CORSE.TIF
The website of the IGN tells us that this map uses the NTF reference system (New Triangulation French), with the Lambert projection II extended. The conversion command will be as follows:
gdal_translate -of ECW -co "TARGET=88" -co "DATUM=NTF" -co "PROJ=LM2FRANC" CORSE.TIF CORSE.ecw
However, we note that the map is surrounded by an unnecessary white border. It is possible to convert only a part of the map, using the -srcwin option of the gdal_translate command:
gdal_translate -of ECW -co "TARGET=88" -co "DATUM=NTF" -co "PROJ=LM2FRANC" -srcwin 63 84 980 1930 CORSE.TIF CORSE.ecw
For the Linux users (or Windows with CygWin), here's a script that converts the SCAN100 map.
Download for example the image BlueMarble. The coordinates of the upper left corner are -180 °, 90 ° and those of the lower right corner are 180°,-90°. The datum is WGS84, and the projection is GEODETIC.
The command you can use for the conversion is:
gdal_translate -of ECW -co "TARGET=94" -co "DATUM=WGS84" -co "PROJ=GEODETIC" -a_ullr -180 90 180 -90 land_shallow_topo_2048.jpg BlueMarble.ecw
If you have a file in ECW format not containing the whole georeferencing information (datum, projection and extents), it is possible to add this information without having to decompress / recompress the file with gdal_translate. To do this, you may use the tool ECW Header Editor, that you can download at ERDAS.
To georeference the image, you must proceed as follows:
It is also possible to use gdal_edit , that works on Windows, MacOS and Linux.
There are lots of maps for OziExplorer. Thus, we are going to show step by step, on three practical examples, how to convert your maps to ECW format.
Often it occurs that calibration files for Oziexplorer do not contain the correct information on the projection and the datum. This is because some people use OziExplorer without sufficient knowledge, sometimes without even taking the time to try to understand the datums and projections.
There is a simple test to be carried out on a calibration file. The principle is to verify that the edges of the map are parallel to the axes of the projection.
To start, display the .map file contents (it contains plain text). In general, the file contains the coordinates of four control points, most often the four corners of the map. To ensure that the map is aligned with the axes of the projection, you just have to check that:
Point | Easting | Northing |
---|---|---|
Coordinates of the upper left corner | 0 | 2700000 |
Coordinates of the upper right corner | 1100000 | 2700000 |
Coordinates of the lower right corner | 1100000 | 1600000 |
Coordinates of the lower left corner | 0 | 1600000 |
In this first example, we see that the map is well positioned. Indeed:
Point | Easting | Northing |
---|---|---|
Coordinates of the upper left corner | 4.269040 | 45.882684 |
Coordinates of the upper right corner | 4.912734 | 45.870023 |
Coordinates of the lower right corner | 4.891744 | 45.422152 |
Coordinates of the lower left corner | 4.253713 | 45.434813 |
In this second example, we see that the map is misaligned. Indeed:
Note: This simple method is able to prove that the projection indicated in the .map file is incorrect. It does not check that the projection, datum and coordinates are correct, this should be done by displaying known points in ttMaps.
Here is an example, with a .map file found on a forum:
.map file lines | Description |
---|---|
Map Datum,NTF France | Datum |
Map Projection,(II) France Zone II,PolyCal,No,AutoCalOnly,No,BSBUseWPX,No | Projection |
Image Width,44000 | Image width, in pixels |
Image Height,44000 | Image height, en pixels |
Point01,xy, 0, 0,in, deg, , ,N, , ,E, grid, , 0, 2700000,N | Coordinates of the upper left corner |
Point02,xy,44000, 0,in, deg, , ,N, , ,E, grid, , 1100000, 2700000,N | Coordinates of the upper right corner |
Point03,xy,44000,44000,in, deg, , ,N, , ,E, grid, , 1100000, 1600000,N | Coordinates of the lower right corner |
Point04,xy, 0,44000,in, deg, , ,N, , ,E, grid, , 0, 1600000,N | Coordinates of the lower left corner |
This table contains all the information necessary to create a georeferenced ECW file.
The easiest way to make the conversion is to use GDAL:
gdal_translate -of ECW -co "TARGET=94" -co "DATUM=NTF" -co "PROJ=LM2FRANC" -co "LARGE_OK=YES" -a_ullr 0 2700000 1100000 1600000 map.png map.ecw
Note : The LARGE_OK=YES option here is essential, because the size of the map (44000 x 44000 x 3 = 5808000000 bytes) exceeds 500 Mb.
Here is a second example :
.map file lines | Description |
---|---|
WGS 84,WGS 84, 0.0000, 0.0000,WGS 84 | Datum |
Map Projection,Latitude/Longitude,PolyCal,No,AutoCalOnly,No,BSBUseWPX,Yes | Projection |
Image Width,5000 | Image width, in pixels |
Image Height,5000 | Image height, en pixels |
Point01,xy, 0, 0,in, deg, 45, 52.96104,N, 4, 16.1424,E, grid, , , ,N | Coordinates of the upper left corner (in degrees + decimale minutes) |
Point02,xy, 5000, 0,in, deg, 45, 52.20138,N, 4, 54.76404,E, grid, , , ,N | Coordinates of the upper right corner (in degrees + decimale minutes) |
Point03,xy, 5000, 5000,in, deg, 45, 25.32912,N, 4, 53.50464,E, grid, , , ,N | Coordinates of the lower right corner (in degrees + decimale minutes) |
Point04,xy, 0, 5000,in, deg, 45, 26.08878,N, 4, 15.22278,E, grid, , , ,N | Coordinates of the lower left corner (in degrees + decimale minutes) |
We see immediately that the map is not aligned with the WGS84 projection. The main challenge will be to find the correct projection and datum.
As it is a French map, it's not very difficult: Most french maps use the NTF datum and the extented Lambert II projection (at the exception of some maps of Corsica that use the Lambert IV projection).
We'll check that by converting the coordinates of the four corners of the map into NTF/extented Lambert II. There are many softwares to convert coordinates, use whatever you prefer.
Points | Longitude (WGS84) | Latitude (WGS84) | X (Lambert IIe) | Y (Lambert IIe) |
---|---|---|---|---|
Upper left corner | 4.269040 | 45.882684 | 750000.06 | 2099889.00 |
Upper right corner | 4.912734 | 45.870023 | 799993.98 | 2099915.04 |
Lower right corner | 4.891744 | 45.422152 | 799982.76 | 2050105.46 |
Lower left corner | 4.253713 | 45.434813 | 750024.37 | 2050092.08 |
This map has probably been calibrated manually, and there are errors of a few tens of meters. After rounding results, we get:
Points | X (Lambert IIe) | Y (Lambert IIe) |
---|---|---|
Upper left corner | 750000 | 2100000 |
Upper right corner | 800000 | 2100000 |
Lower right corner | 800000 | 2050000 |
Lower left corner | 750000 | 2050000 |
So we see that the map is well aligned with respect to the axes of the projection NTF/extended Lambert II, and we can now convert it:
gdal_translate -of ECW -co "TARGET=94" -co "DATUM=NTF" -co "PROJ=LM2FRANC" -a_ullr 750000 2100000 800000 2050000 map.png map.ecw
Note : The LARGE_OK=YES option is not useful, because the size of the map (5000 x 5000 x 3 = 75000000 bytes) does not exceed 500 MB
To understand this example, it is necessary to know the reference system used in the United Kingdom. Read for example http://en.wikipedia.org/wiki/British_national_grid_reference_system.
.map file lines | Description |
---|---|
Ord Srvy Grt Britn,WGS 84, 0.0000, 0.0000,WGS 84 | Datum |
Map Projection,(BNG) British National Grid,PolyCal,No,AutoCalOnly,No,BSBUseWPX,No | Projection |
IWH,Map Image Width/Height,32704,32576 | Taille de l'image, en pixels |
Point01,xy, 200, 128,in, deg, , ,N, , ,W, grid, HV, 01000, 00000,N | |
Point02,xy,32400, 128,in, deg, , ,N, , ,W, grid, HW, 62000, 00000,N | |
Point03,xy,32400,32328,in, deg, , ,N, , ,W, grid, NG, 62000, 39000,N | |
Point04,xy, 200,32328,in, deg, , ,N, , ,W, grid, NF, 01000, 39000,N |
This conversion is more complex than previous ones:
We will begin by converting the coordinates from letters + numbers to fully numerical coordinates. For that, it is enough to know that the squares measure 100km aside and that the reference is the southwest corner of the SV square (see map on Wikipedia). We deduce the following table:
Square | X Offset | Y Offset |
---|---|---|
HV | 0 | 1000 km |
HW | 100 km | 1000 km |
NG | 100 km | 800 km |
NF | 0 km | 800 km |
that allows us to calculate the coordinates of the four control points:
Control Point of reference | Easting | Northing |
---|---|---|
Point01 | 1000 | 1000000 |
Point02 | 162000 | 1000000 |
Point03 | 162000 | 839000 |
Point04 | 1000 | 839000 |
We note in passing that the map is well aligned with respect to the axes of the projection.
Now calculate the coordinates of the upper left corner and lower right corner of the map.
We just have to convert the map:
gdal_translate -of ECW -co "TARGET=90" -co "DATUM=OSGB36" -co "PROJ=TMOSGB" -co "LARGE_OK=YES" -a_ullr 0 1000640 163520 837760 map.png map.ecw
Last modification : 02/01/2014