lowrance2omg
Description
lowrance2omg (written by John Hughes Clarke and James Muggah, October 2013) unpacks Lowrance .sl2 consumer/recreational singlebeam and downscan sonar log files into standard Ocean Mapping Group (OMG) formats:
<outname>.mergedâ OMG-HDCS v3 bathymetry file (toolType = Knudsen_320, 2 beams per ping) storing nadir depth inbeams[0].observedDepth(mm) and pointers (beams[0].offset,beams[0].no_samples) to the full acoustic envelope trace.<outname>.merged.ss_dataâ Sub-bottom / singlebeam acoustic trace data sidecar for<outname>.merged(viewable inswathedâsSE_SUBBOTwinsub-bottom profiler window).<outname>.navâ Binaryjcu_nav_recnavigation file containing unique GPS fixes converted from Lowrance Spherical Mercator meters (positionX,positionY) to WGS84 latitude/longitude.<outname>.trcâ Raw 1600-sample 8-bit acoustic envelope traces (2-sample decimated from the 3216-byte.sl2chunk).<outname>.llzâ ASCII<lat> <lon> <depth_m>soundings (converting Lowrance depth from feet to meters via $\times 0.304$).
Usage
lowrance2omg -start_time <year> <jday> <hour> <min> <sec> [-shift <bytes>] [-v] -in <infile.sl2> -out <outprefix>
Example
lowrance2omg -start_time 2013 287 16 21 31 -in Sonar0001.sl2 -out lowrance_line01
Arguments
| Option | Description | Default |
|---|---|---|
-in <infile.sl2> | Input Lowrance .sl2 binary sonar log file. | Required |
-out <outprefix> | Base output prefix; creates <outprefix>, <outprefix>.nav, <outprefix>.trc, <outprefix>.llz, <outprefix>.merged, and <outprefix>.merged.ss_data. | Required |
-start_time <yr> <jd> <hr> <mn> <sc> | Survey start timestamp (5 integers: Year, Julian Day, Hour, Minute, Second), converted to Unix epoch seconds via stdtime_from_jul_day to anchor summary.refTime. | Required |
-shift <bytes> | Byte offset adjustment applied via fseek(infile, shift, SEEK_CUR) after reading the 10-byte .sl2 file header (format, bytesPerChunk, terminal). | -2 |
-v | Verbose mode: dumps all 35 integer/float header slots of each 140-byte .sl2 ping header and prints decoded timeOffset, positionX, positionY, lowerLimit, waterTemp, speed, track, altitude, and depth. | Disabled |
How It Works
.sl2File Header & Chunk Layout: Reads the 10-byte file header (int format,int bytesPerChunk,short terminal), seeks byshift(default-2bytes), and computesnumChunks = (filesize - 10) / bytesPerChunk.- Ping Header & Trace Extraction: For each chunk, reads
3216bytes (trace), averages adjacent acoustic samples starting at offset143(2+16+125) into a 1,600-byte array (ktrace[1600]), and writesktraceto<outprefix>.trcand<outprefix>.merged.ss_data. - Coordinate & Depth Conversion: Extracts 32-bit fields from the 140-byte ping header:
timeOffset(ms) at byte0(0*4)lowerLimit(ft) at byte44(11*4)depth(ft) at byte64(16*4)speedat byte100(25*4),waterTempat byte104(26*4)positionX(Mercator Easting m) at byte108(27*4),positionY(Mercator Northing m) at byte112(28*4)trackat byte120(30*4),altitudeat byte124(31*4) Converts(positionX, positionY)to WGS84(lat, lon)using radiusOTHER_WGS = 6356752.3142: \(\text{lat} = \left(2\arctan\left(e^{\text{positionY} / R}\right) - \frac{\pi}{2}\right)\frac{180}{\pi}, \qquad \text{lon} = \frac{\text{positionX}}{R}\frac{180}{\pi}\) Whenever(positionX, positionY)changes from the previous ping, writes a newjcu_nav_recto<outprefix>.nav.
- OMG-HDCS
.merged&.merged.ss_dataGeneration: For every ping with non-zerodepth, writes<lat> <lon> <depth * 0.304>to<outprefix>.llzand appends a profile + 2-beam record (toolType = Knudsen_320) to<outprefix>.merged, encoding sample interval scaling intoprofile.samp_rateandprofile.edflagand linkingbeams[0].offsetto the byte offset in<outprefix>.merged.ss_data.