Saturday, January 30, 2016

Converting Weather Maps to BSB echarts


Our goal is to convert weather maps to echarts for use in forecast evaluation (overlaying model forecasts) and general route planning. We started with the easy ones, namely the color maps from OPC that have a nice lat-lon grid on them that lets us scale the margins of the charts. This way we can make a prescription for doing this that does not involve trimming the charts for each conversion.

Underway, however, we are most likely to have access to the black and white tif maps that we can get from saildocs in reduced file size.  The problem that comes up immediately is these maps do not have a nice lat-lon grid; it is shown only every 10ยบ with large blank margins. Thus are simple approach of making the header files by hand does not work for these maps.  I have tried numerous tricks that I thought would work around this, but none succeeded. We are standing by for an easier solution if someone has it. Just post a comment.

One approach that does work is to call up two more custom programs and built the map in several steps.

Step 1. This always has to be done: download the map and convert to a png, and read the dimensions of the chart viewed upright—we typically get the maps sideways as tifs.

Step 2. Georeference the chart and define the borders using MapCal_2, and save what it calls chartcal.dir, which is a text file you can open in notepad.  This step is illustrated here:

Video Note: watching carefully you will see a blunder being made on the bottom right cal point, but it got caught and corrected during a simple check at the end.... nice to have such things to see how this works!  There is also an error early on calling a png file a gif file. Unfortunately, nothing to learn from that if we rule out author evaluations. 



Step 3. Use the program mc2bsbh to build the header from the chartcal.dir. The extension of the header made this way is .hdr.  We need to change that to .kap before using imgkap (you could also create one with the right name, but this is just as easy).

Step 4. Proceed to convert the png to a kap file with the header just created using imgkap.




In an earlier video-illustrated post we did this making the header file by hand, which worked for easy to scale charts that have a full lat-lon grid. That does not work for these BW maps with large vacant borders and few reference lines, which is why we move to this procedure.... at least till we learn a better way. On the other hand, once you have these utility programs in a folder, it is probably fastest to use this present method for all charts.

( I should mention for completeness, that if one has the high-end navigation program called Expedition, you don't need any of this. You just import the image, georeference two opposite corners with a slick, fast interface they have, and you are done, and ready to view the map as an interactive chart.  It is then saved for later use or for overlaying model forecasts, etc. One minute would be a long estimate of the time it takes from beginning to end! )

In principle, there is a package of utilities called kapgen that will do all of what we describe above at once, but I have not had any luck yet with using that.

It took long enough to learn to do what we do here that I want to document this process before I forget the details; later we might return to figuring out what we are doing wrong with kapgen.

All of these methods are described in the OpenCPN manual or FAQ, or links they provide. It seems easy enough when reading about it, but there are nuances that I hope we point out here.

Program sources:

imgkap.exe from http://www.dacust.com/inlandwaters/imgkap/

mc2bsbh.exe from http://www.dacust.com/inlandwaters/mapcal/

MapCal_2.exe comes from installing the program SeaClear. Install the program, then look in the Programs Files directory, and from their you can make a shortcut to MapCal_2.exe for your desktop or other folder you are usin for the conversions.

-----------------

For reference, here is the header file we created for the epac surface analysis, a map that is 1446 x 1728. With this, all you need is imgkap to make a chart out of any epac surface analysis. This is for the full size maps. We need to make another one for the saildocs versions that are half this size.

! Created by mc2bsbh beta09 - Use at your own risk!
VER/2.0
BSB/NA=pyba90
    NU=pyba90,RA=1446,1728,DU=628
KNP/SC=50000000,GD=WGS84,PR=MERCATOR,PP=UNKNOWN
    PI=UNKNOWN,SP=UNKNOWN,SK=0.0,TA=90.0
    UN=UNKNOWN,SD=none
    DX=2021.6,DY=2021.6
OST/1
REF/1,126,262,60,-170
REF/2,126,1582,20,-170
REF/3,1325,262,60,-120
REF/4,1325,1582,20,-120
CPH/0.0
PLY/1,64.940016,-175.045872
PLY/2,14.3864206,-175.045872
PLY/3,14.3864206,-115.162636
PLY/4,64.940016,-115.162636
DTM/0,0







1 comment:

Lorenzo Stewart said...

Good Day :
What do mayor alphabet letters "BSB" actually stand for ?
Tks!

brown0@speedy.com.ar