The BSB file format

A nautical chart set in BSB format consists of several files: main .BSB file and one or more .KAP files. A main BSB file contains chart set meta-data information (chart description, function, enumeration of .KAP files. Note that NOAA BSB charts are meant to be exact equivalent of paper charts, so they contain the same number of sub-charts (paper pages). The .BSB file is unusual in that it contains both ASCII text and binary data concatenated together and structured as follows:

Text Header

Although described as proprietary by NOAA, much of the information in the ASCII text header is self explanatory. Each line begins with a 3 character token followed by a slash "/". The remainder of the line depends upon the token, but in general consists of a list of comma separated values. If the list of values is too long for 80 columns, the values for the token are continued on the next line by prefixing the new line with 4 spaces. Comments are indicated with a leading "!".

    ! An example BSB text header
    VER/3.0
    BSB/NA=Australia 3000000
        NU=,RA=625,480,DU=50
    KNP/SC=3000000,GD=,PR=LAMBERT CONFORMAL CONIC,PP=145.0
        PI=0.0,SP=Unknown,0,SK=0.0
        UN=METRES,SD=,DX=6000.0,DY=6000.0
    OST/1
    IFM/3
    RGB/1,199,231,252
    RGB/2,174,234,84
    RGB/3,255,254,206
    RGB/4,226,65,6
    DTM/0.0,0.0

The text header is terminated with a <Control-Z><NUL> sequence (ASCII characters 26 and 0). Each line starts with a tag terminated by a '/'. The tags are usually 3 letters. The lines are terminated with the NL character. However, logical lines can continue when next line starts with spaces. Tags:

Geotransformation

The WPX,WPY,PWX,PWY tags define coeffitients of a polynomial used to convert x,y of chart to latitude/longitude and vice versa. The tags specify order of the polynomial (first number) and then list corresponding coefitients. The polynomial has a general form of :
    coeff[0] + coeff[1]*lon + coeff[2]*lat +
    coeff[3]*lon*lon +
    coeff[4]*lon*lat +
    coeff[5]*lat*lat +
    coeff[6]*lon*lon*lon +
    coeff[7]*lon*lon*lat +
    coeff[8]*lon*lat*lat +
    coeff[9]*lat*lat*lat +
    coeff[10]*lat*lat*lat*lat +
    coeff[11]*lat*lat*lat*lat*lat
where: Note: the same polynomial, just with different coeffitients (as read from tags) is used for all transformations. See bsb_LLtoXY/bsb_XYtoLL functions for use example.

Binary Section

The first byte after the <Control-Z><NUL> sequence is a single byte storing the depth of the image, duplicating the information from the IFM token.

Next are one or more rows of run-length encoded raster data terminated by <NUL> characters. Each row, when decompressed, represents one horizontal line of the image.

Rows start with one or more bytes representing the row number. The storage of the row number finishes when the byte is less than 128. Row numbering starts at 1 rather than 0.

The next byte will indicate the color of a pixel using a colormap index. The nature of the bitstream packing limits the color depth to 7 bits. Therefore bytes of value greater than 127 as used to indicate that the next byte stores the 'run' length in addition to storing the colormap index.

Authors/Contributors

The libbsb library and this web page was written by Stuart Cunningham with GIS related advice from Anuradha Suraparaju. Additional improvements made by Michal Krombholz. The big thanks go to Tom Gray for researching polynomial form of geotransfomration. Feedback is welcome.

Copyright (©) 2000-2007 Stuart Cunningham.

SourceForge.net Logo Valid HTML 4.01! Valid CSS!