Sunday, December 15, 2019

How to Make an RNC eChart From a Chart Image

Of the several earlier notes (and videos) we have on this process, this note here effectively outdates all the earlier ones.

 A typical raster navigational chart (RNC) is composed of two files. One with extension .KAP and one with .BSB. The latter is a text file including metadata about the chart and the region it covers. The former is the formatted image file of the chart itself. The format originally developed by MapTech is discussed here. The .KAP file is unusual in that it has a readable multi-line ascii text section followed by the binary image code.

This subject may have some renewed interest in the future in that NOAA will be discontinuing paper charts and the RNC echarts made from them. Also of note, is Google Earth has recently changed their policy and now offers a standard mercator projection of the earth, which means we can make our own nautical charts more easily this way now for regions that might not be well charted.

Using OpenCPN Weatherfax Plugin

I know of two ways to make the KAP files. One is use OpenCPN weatherfax (wefax) plugin; the other uses three free PC utilities. The wefax method is very easy and takes just a minute or two. The only disadvantage to this method is that (for the time being) you cannot specify the units if they are feet and other metadata cannot be edited. This means the scale will be reported incorrect and the depth units could be wrong if native units are feet. However, if you can overlook those factors and just need a chart that looks good and is properly georeferenced, that can be passed on to others, then the OpenCPN wefax method is the way to go. It is explained in the short video below. This  method is limited to image files of about 40 MB, but that should not be restrictive.

  Making KAP file with OpenCPN wefax plugin     

If we want to get the chart metadata correct so that it reports properly on the chart, then we have a longer process, but still direct once the prescription is known, which we outline here. This procedure is explained online in various formats, so this is just a local rewording and a focus on only one of several variations. To read other descriptions, search the Cruisers Forum, OpenCPN section, on ImgKap.

Using ImgKap.exe

I have earlier notes and videos on this process, but they are more complex than needed as they  calibrate the images manually and then create the header files manually as well. Here we use two utilities to do that.  For now we look at using ImgKap.exe directly, streamlined as best I can do. Again, there may be other, easier ways.

To accomplish this we need 3 free PC programs, used in this order:

    MapCal_2.exe (1.2 MB, 2/17/2013)
    mc2bsbh.exe (0.23 MB, 3/15/2010)
    imgkap.exe (3.6 MB, 1/24/2016)

The first has a normal PC windows user interface, but the second two must be run from a Windows command line, which is not familiar process to all, so we outline the steps and provide a video demo.

MapCal_2.exe is used to georeference the chart image. It is not downloaded directly, but obtained by downloading and installing an echart program called Sea Clear II that is available at http://www.sping.com/seaclear. After installing the program, look in c:\Program Files (x86) and you will see the program. You can run it from there or copy it to move to the folder we will use.  It does not require other components.  Sea Clear is a program that was way ahead of its time; this was a function it included that let you make charts out of any image. The charts it makes, however, only work in Sea Clear, and now as time has passed we have OpenCPN as a more versatile tool. But we fall back here to use a Sea Clear utility. This function creates a calibration file called CHARTCAL.DAT.

mc2bsbh.exe stands for MapCal to BSB chart header.  We use it to make the metadata part of the KAP file from the output of MapCal. You can download mc2bsbh at http://www.dacust.com/inlandwaters/mapcal along with instructions for its use, but these will be summarized here. Note that there are other proposed ways to do this at that site, including links to things that are supposed to make it easier, but I have not figured out how to use those properly, so I proceed with this basic approach. This function uses the calibration file CHARTCAL.DAT to create a header_file.hdr.

imgkap.exe is the main tool for putting the header file with the image file to make the KAP file. This is the main tool in that in principle we could calibrate the image manually and also create the header file manually without the first two utilities, but that is tedious and prone to error.  You can download imgkap at http://www.dacust.com/inlandwaters/imgkap (I used to have articles and videos on those two steps, but this note replaces all of those. In retrospect, it is almost comical how complex those early notes are! They were made before I learned of other options.)

Procedure (text followed by a video)

Step 1. Download your chart or other image and trim it to the area you want. The stock MS Paint is one way to do that on a PC. Then consider the size. We want it as small as possible that meets your needs. So zoom in on some section to see what it looks like, then duplicate it and reduce it by 50% and look again. MapCal will take things as large at 60 or 70 MB but it takes a while for it to load.

We will use a samples of training charts that we get at https://historicalcharts.noaa.gov. At the bottom of the page, select "training charts," and search. We already have online 18465TR, 1210TR and 12221TR. For now we will do Block Island Sound 13205TR. These native files are about 35 MB in JPG format.

Use MS Paint or other program to convert this to a .PNG file, which is what MapCal needs.  We start with 13205TR-05-1991.JPG (34.7 MB, 14,000 x 17500 pixels, at 350 dpi) then convert to PNG and change the file name to what you want your chart file to be called, in our case 13205TR.PNG (129.7 MB), which is too big, so reduce by 50% to get 13205TR.PNG (39.8 MB).

Now make a folder on your desktop called "IMGKAP_files" and put all three programs you need into it along with the image file itself. (You can go to program files (x86) and copy mapcal_2 to copy here.)

Now open MapCal and then choose open file and load your PNG image into MacCal and note it will take awhile to load. It may say program not responding, but just wait. This size takes about  3 minutes.  If you have to stop it for any reason or it fails to load, then it is best to restart your PC. We have to do this because MapCal does not close down properly when you close it or it closes itself.

Once the image loads it asks for info on the chart info. If this screen does not show, then click Edit / Chart Info.



Then put the cross hairs in a corner and right click, then enter the lat Lon, then do the other 3 corners and Save. It will write a file called CHARTCAL.DIR in the same folder it found the image file. See video below for examples. This file can be viewed in Notepad, if desired.

Step 2. Now we make the header file from CHARTCAL.DIR.

In the Windows search field bottom left, type cmd, then click Command prompt and a window shows up, with the user showing. Then type "CD Desktop\IMGKAP_files" and press enter.  You should see something like

C:\Users\macdavid\Desktop\IMGKAP_files>

If you make a mistake, use up arrow to repeat, then backspace as needed, fix it, then right space to the end and enter.

Then type mc2bsbh.exe CHARTCAL.DIR and press enter

You will have

C:\Users\macdavid\Desktop\IMGKAP_files>mc2bsbh.exe CHARTCAL.DIR

This will create a file called 13205TR.hdr in the same folder. This file can be viewed in Notepad, if desired.

Now go the folder now and rename that file to 13205TR-hdr.kap

Step 3. Now we combine header and image to make the KAP file using imgkap

In the same cmd line
C:\Users\macdavid\Desktop\IMGKAP_files>

Now type imgkap.exe 13205TR.png  13205TR-hdr.kap  to see this

C:\Users\macdavid\Desktop\IMGKAP_files>13205TR.png  13205TR-hdr.kap

Press enter and this will create the chart as 13205TR.kap, which is ready to load into any echart program.  Below is a video illustrating this process.

Making KAP file with imgkap.exe

No comments: