Humminbird Side Imaging Forums

Software and Software Development => Other 3rd Party Software => Topic started by: adriank on May 08, 2013, 09:14:11 PM

Title: Interpreting Latitude and Longitude in SON files?
Post by: adriank on May 08, 2013, 09:14:11 PM
Hi All

I've been trying to build a batch converter to extract tracks and depths from several hundred DAT/SON files that I have. The info from this post http://forums.sideimagingsoft.com/index.php?topic=16.0 (http://forums.sideimagingsoft.com/index.php?topic=16.0) has been pretty much exactly what I need except for the interpretation of the Latitude and Longitude values. Using the byte map in the above thread I've been converting the Lat/Lon bytes using Int32 and getting values like Lon: 16226043 Lat: -4557743. I know they equate to 145.75528834210039 and -38.032398555522214 but don't know the conversion function or even if I'm doing the byte conversion correctly (I do the bit swap from Big to Little endian).

The DAT files come from a 998c HD SI Combo.

Anyone out there have the answer?

Adrian
Title: Re: Interpreting Latitude and Longitude in SON files?
Post by: RGecy on May 09, 2013, 01:57:04 AM
Adrian, of course I have the answer! ;D

I will post the code here tomorrow when i can.  The unit stores the coordinates in UTM not lat lon.  There are several good sources on the net that have these formulas, but getting the correct one can be tricky.  The datum multiplier is key to getting precise conversions.  Have a look at the webpage below and see what you think about the math.  ::) ::)

http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system (http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system)


Robert
Title: Re: Interpreting Latitude and Longitude in SON files?
Post by: adriank on May 09, 2013, 02:16:07 AM
ah Robert you're a legend . I had an idea they were in UTM but the numbers weren't right and there was no zone. Found some useful code at http://bb.sideimageforums.com/viewtopic.php?p=485 (http://bb.sideimageforums.com/viewtopic.php?p=485) but that conversion was out by 0.7degrees.

Cheers

Adrian
Title: Re: Interpreting Latitude and Longitude in SON files?
Post by: adriank on May 09, 2013, 10:59:10 PM
OK I can refine my problem a little more. I have code which coverts UTMtoDeg and DegtoUTM which works fine. The main issue I'm having is that the N & E from the SON file don't resemble the N & E for the true coordinates. I'm either converting them from bytes wrong or there is something done to the values before feeding them into the UTMtoDeg conversion. I'm assuming the UTM Zone is from common knowledge as I don't see it in the SON read out. So here is an example:

When I convert the SON bytes to Int32 I get N: -4557743 (position 20-23) and E: 16226043  (position 15-18)
The coordinates they should convert to is Lat: -38.03239969 Lon: 145.7552883 which in UTM is actually N: 5789858.812 (Raw N: -4210141.188) and E: 390763.6466 for Zone 55

So I guess what I need is the process to get those SON N&E correct before I convert to Lat/Lon.

Hope this makes it a bit easier to solve.

Adrian


Title: Re: Interpreting Latitude and Longitude in SON files?
Post by: RGecy on May 10, 2013, 04:15:13 PM
Might want to check how you are doing the bit swap.  You said from big to little endian, but the file is stored in big endian. 

So I would assume you are reading in litlle endian and converting to big endian.

Robert
Title: Re: Interpreting Latitude and Longitude in SON files?
Post by: adriank on May 13, 2013, 11:05:26 PM
Robert

I'm reading the file's byte sections (big endian) into .NET and swapping the bits via Array.Reverse() to make it little endian which I then convert using BitConverter.ToInt32(). It seems to work fine for all the other data sections (date, depth, etc) in the line!?! The graphic show the basic output I'm getting for the first several lines. Some parts aren't converted to numeric datatypes.

I've used HumViewer to convert the same DAT file and it produces the correct lat/lons so I know the file should be fine. Could I send you the DAT/SON files to see if your code correctly interprets it? It's less than a Mb.

Cheers

Adrian
Title: Re: Interpreting Latitude and Longitude in SON files?
Post by: RGecy on May 14, 2013, 10:48:12 PM
Sure, send me the file. Or post it here.  You will need to zip it.

.Net will be reading it in Little Endian.  Either way, if you are reversing it, it wouldnt matter.  Like you said, it works for the other values.  It may be your conversion from UTM. 

Robert
Title: Re: Interpreting Latitude and Longitude in SON files?
Post by: adriank on May 15, 2013, 03:34:15 AM
Yeah maybe something is wrong with the UTM conversion but I've also used the spread sheet at this link with the same results. http://www.uwgb.edu/dutchs/UsefulData/UTMFormulas.HTM (http://www.uwgb.edu/dutchs/UsefulData/UTMFormulas.HTM)
All I know, that at least for the first line, the results should end up Lat: -38.03239969 Lon: 145.7552883. I've attached a zip of the DAT/SON files for you to have a look at.

Thanks heaps for this.

Adrian
Title: Re: Interpreting Latitude and Longitude in SON files?
Post by: adriank on May 27, 2013, 01:59:51 AM
Hi Robert

Sorry to bug you but wondered if you managed to look at that DAT file? Mainly I want to know what Easting and Northing values you get out of it. If you get the same as me then my UTM conversion is the problem. If you get different Easting and Northing values to me then it's my binary conversion that's the problem.

Cheers

Adrian
Title: Re: Interpreting Latitude and Longitude in SON files?
Post by: adriank on February 09, 2015, 06:23:35 PM
Answers in this thread. http://forums.sideimagingsoft.com/index.php?topic=7785.0 (http://forums.sideimagingsoft.com/index.php?topic=7785.0)
SimplePortal 2.3.3 © 2008-2010, SimplePortal