I have some gps sensor data which uses signed 24 bits to represent latitude and longitude each. I want to convert this data in more readable degrees, minutes and seconds format.
I have searched a lot but no algorithm is working for me. I would like to do this in python.
The spec sheet tells the following
Byte [8] > Value: MSB of the UP501 received Latitude
Byte [9] > Value: CSB of the UP501 received Latitude
Byte [10] > Value: LSB of the UP501 received Latitude
Byte 8, 9 and 10 represent the latitude. The north-south latitude is encoded using a signed 24 bit word where -2^23 corresponds to 90° south (the South Pole) and 2^23- 1 corresponds to 90° north (the North Pole). The equator corresponds to 0.
Byte [11] > Value: MSB of the UP501 received Longitude
Byte [12] > Value: CSB of the UP501 received Longitude
Byte [13] > Value: LSB of the UP501 received Longitude
Byte 11, 12 and 13 represent the longitude. The east-west longitude is encoded using a signed 24 bit word where -2^23 corresponds to 180° west and 2^23 -1 corresponds to 180° east. The Greenwich meridian corresponds to 0.
Example data (from 8-13 bytes)
1E 55 9C 1C 69 5A
should give 21°19′44″N, 39°57′13″E
EDIT: After the first comment, here is the problem Every where I have seen is the 32 bit representation of the coordinates. Those methods are not working for me as I do not get what I expect. Not even close.
Is there a better way for this conversion?
int("1E559C", 16)
, I imagine each degree would be something like93206.7
, diving would give21.328883171081543
but I know very little about calculating lat and long – Padraic Cunningham