kirpidik
Posts: 21
Joined: Tue Feb 02, 2021 2:40 pm

knots to km/h

Thu May 06, 2021 10:18 am

hi all, i am getting this code from adafruit gps.
There is a way to print the wind speed in km / h or m / s

Code: Select all

print("Latitude: {0:.6f} degrees".format(gps.latitude))
        print("Longitude: {0:.6f} degrees".format(gps.longitude))
        print("Fix quality: {}".format(gps.fix_quality))
        # Some attributes beyond latitude, longitude and timestamp are optional
        # and might not be present.  Check if they're None before trying to use!
        if gps.satellites is not None:
            print("# satellites: {}".format(gps.satellites))
        if gps.altitude_m is not None:
            print("Altitude: {} meters".format(gps.altitude_m))
        if gps.speed_knots is not None:
            print("Speed: {} knots".format(gps.speed_knots))
        if gps.track_angle_deg is not None:
            print("Track angle: {} degrees".format(gps.track_angle_deg))
        if gps.horizontal_dilution is not None:
            print("Horizontal dilution: {}".format(gps.horizontal_dilution))
        if gps.height_geoid is not None:
            print("Height geo ID: {} meters".format(gps.height_geoid))



User avatar
neilgl
Posts: 3254
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: knots to km/h

Thu May 06, 2021 10:24 am

A knot is 1.852 km/h (approx. 1.151 mph) [wikipedia] so multiply your knots value by 1.852 to get km/h

kirpidik
Posts: 21
Joined: Tue Feb 02, 2021 2:40 pm

Re: knots to km/h

Thu May 06, 2021 10:32 am

I know, I mean how I change the code

kirpidik
Posts: 21
Joined: Tue Feb 02, 2021 2:40 pm

Re: knots to km/h

Thu May 06, 2021 10:33 am

Resolved

User avatar
neilgl
Posts: 3254
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: knots to km/h

Thu May 06, 2021 11:14 am

OK, I had this:

Code: Select all

if gps.speed_knots is not None:
  print("Speed: {} km/h ".format(gps.speed_knots*1.852))

User avatar
Gavinmc42
Posts: 5702
Joined: Wed Aug 28, 2013 3:31 am

Re: knots to km/h

Thu May 06, 2021 11:52 am

1 knot does doesn't seem that fast.
A length of rope and a bit of wood thrown overboard and it takes 1 hour to get to the first knot?
What was the distance between knots?
https://en.wikipedia.org/wiki/Knot_(unit)

I wonder who got to wind the rope back up?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

gordon77
Posts: 5691
Joined: Sun Aug 05, 2012 3:12 pm

Re: knots to km/h

Thu May 06, 2021 12:27 pm

From your link ... Knots tied at a distance of 47 feet 3 inches (14.4018 m) from each other,

bjtheone
Posts: 1304
Joined: Mon May 20, 2019 11:28 pm
Location: The Frozen North (AKA Canada)

Re: knots to km/h

Thu May 06, 2021 1:29 pm

You have got to love a unit of measure that is totally tied to the size of the world you are sailing on. Though I suppose it is more valid than the length of the king's forearm or emperor's foot.

User avatar
davidcoton
Posts: 6270
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: knots to km/h

Thu May 06, 2021 2:52 pm

bjtheone wrote:
Thu May 06, 2021 1:29 pm
You have got to love a unit of measure that is totally tied to the size of the world you are sailing on. Though I suppose it is more valid than the length of the king's forearm or emperor's foot.
Well, the original definition of the kilometre was one ten thousandth of the distance from the equator to the north pole through Paris.
Location: 345th cell on the right of the 210th row of L2 cache

Heater
Posts: 18261
Joined: Tue Jul 17, 2012 3:02 pm

Re: knots to km/h

Thu May 06, 2021 4:28 pm

bjtheone wrote:
Thu May 06, 2021 1:29 pm
You have got to love a unit of measure that is totally tied to the size of the world you are sailing on. Though I suppose it is more valid than the length of the king's forearm or emperor's foot.
I'm not sure what you are getting at there. It is that praise or criticism?

I would say that a unit of measure that is related to the "world" you are measuring in is a very sensible idea. In this case related to astronomy, and time. Much easier to deal with than some other random unit that comes from a totally different field and does not neatly fit anything.

As it happens we landed on decimal and the SI units. Despite the fact that base 10 is the most inconvenient base no matter what you do. Thank you French.

I would say meters are about as daft as the length of a standard King's forearm.
Memory in C++ is a leaky abstraction .

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11278
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: knots to km/h

Thu May 06, 2021 4:40 pm

Code: Select all

pi@raspberrypi:~ $ sudo apt install units
pi@raspberrypi:~ $ units
Currency exchange rates from FloatRates (USD base) on 2018-10-20 
3072 units, 109 prefixes, 109 nonlinear units

You have: 1 knot
You want: kilometres per hour
	* 1.852
	/ 0.5399568
I learnt about that tool from http://ibiblio.org/harris/500milemail.html. I love the concept of milli-lightseconds.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

kheylen25
Posts: 15
Joined: Sun Apr 11, 2021 7:58 am

Re: knots to km/h

Thu May 06, 2021 7:07 pm

Anyways, I'm soooo glad they made things easier now (from Wikipedia):
The metre is currently defined as the length of the path travelled by light in a vacuum in 1/299 792 458 of a second.
Good to know, I've not always a measuring tool at hand :mrgreen:

User avatar
jahboater
Posts: 7081
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: knots to km/h

Thu May 06, 2021 7:18 pm


User avatar
Gavinmc42
Posts: 5702
Joined: Wed Aug 28, 2013 3:31 am

Re: knots to km/h

Thu May 06, 2021 9:00 pm

.Except for the Kilogram unit.
They have to figure out a new one that no ordinary person can copy or understand.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
davidcoton
Posts: 6270
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: knots to km/h

Thu May 06, 2021 10:13 pm

Gavinmc42 wrote:
Thu May 06, 2021 9:00 pm
.Except for the Kilogram unit.
They have to figure out a new one that no ordinary person can copy or understand.
They have. All those "standard" kilograms are now 1 kg paperweights. The kilogram is defined by defining Plank's constant. There are no arbitrary prototype definitions now.
Location: 345th cell on the right of the 210th row of L2 cache

User avatar
HawaiianPi
Posts: 6342
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: knots to km/h

Thu May 06, 2021 11:33 pm

Gavinmc42 wrote:
Thu May 06, 2021 9:00 pm
Except for the Kilogram unit.
They have to figure out a new one that no ordinary person can copy or understand.
davidcoton wrote:
Thu May 06, 2021 10:13 pm
They have. All those "standard" kilograms are now 1 kg paperweights. The kilogram is defined by defining Plank's constant. There are no arbitrary prototype definitions now.
https://news.mit.edu/2019/kilo-standard-change-0516 wrote: ...a kilo is to be defined by fixing the numerical value of a fundamental constant of nature known as the Planck constant. This constant relates the energy of a photon to its frequency, and is referred to by the letter h. It is now defined as 6.62607015 times 10-34 kilograms times square meters per second, thereby defining the kilogram in terms of the second and the meter. Since the second and meter are already defined completely in terms of physical constants, the kilogram is now also defined only in terms of fundamental physical constants.
The only thing that comes to mind here is, be careful what you wish for... :? :lol:

Although I believe that davidcoton should have described the previous measuring devices as approximately 1 kg paperweights. ;)
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

User avatar
Gavinmc42
Posts: 5702
Joined: Wed Aug 28, 2013 3:31 am

Re: knots to km/h

Thu May 06, 2021 11:45 pm

The only thing that comes to mind here is, be careful what you wish for... :? :lol:
Although I believe that davidcoton should have described the previous measuring devices as approximately 1 kg paperweights. ;)
I must have missed the news announcement of the Kilograms retirement.
Now it can rust away in peace or grows heavier until it turns into a black hole.

Gravity is not the same all over the planet, so how do they use this new measurement to "weight" out the Salmon or mince meat in the supermarket?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

pfletch101
Posts: 653
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: knots to km/h

Fri May 07, 2021 1:40 pm

Gavinmc42 wrote:
Thu May 06, 2021 11:45 pm
Gravity is not the same all over the planet, so how do they use this new measurement to "weight" out the Salmon or mince meat in the supermarket?
The way they always have: secondary standards, derived from the primary one.

bjtheone
Posts: 1304
Joined: Mon May 20, 2019 11:28 pm
Location: The Frozen North (AKA Canada)

Re: knots to km/h

Fri May 07, 2021 5:39 pm

Heater wrote:
Thu May 06, 2021 4:28 pm
bjtheone wrote:
Thu May 06, 2021 1:29 pm
You have got to love a unit of measure that is totally tied to the size of the world you are sailing on. Though I suppose it is more valid than the length of the king's forearm or emperor's foot.
I'm not sure what you are getting at there. It is that praise or criticism?

I would say that a unit of measure that is related to the "world" you are measuring in is a very sensible idea. In this case related to astronomy, and time. Much easier to deal with than some other random unit that comes from a totally different field and does not neatly fit anything.

As it happens we landed on decimal and the SI units. Despite the fact that base 10 is the most inconvenient base no matter what you do. Thank you French.

I would say meters are about as daft as the length of a standard King's forearm.
It gets a plus for being tied to something relatively fixed in the worldview of the time and a minus for not being portable. Of course that does open the door for bragging rights, with teeny tiny print... My boat goes this fast on...

Even as a child of imperial, and still not being able to visualize in dimensions in metric, I have to concede is a much much better system than imperial. Of course the insane mashup of having material that its manufactured in feet in length and width (the 4 by 8/10/12 sheet goods) and in mm for thickness is truly messed up and makes for lovely stackup calcs.

I am not sure how you can claim base 10 is bad, when the other choice is imperial with its brilliant unit steps (12, 16, 3, 5280, etc) and whomever the wanker was that decided US gallons should be different just because....

pidd
Posts: 2101
Joined: Fri May 29, 2020 8:29 pm
Location: Wirral, UK
Contact: Website

Re: knots to km/h

Fri May 07, 2021 5:47 pm

I was wondering why an inch was such a simple ratio of a millimetre so looked that up the other day, turns out the inch was purposely changed to match the ratio as a rough approximation to various other lengths called an inch.

pfletch101
Posts: 653
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: knots to km/h

Fri May 07, 2021 6:10 pm

bjtheone wrote:
Fri May 07, 2021 5:39 pm
I am not sure how you can claim base 10 is bad, when the other choice is imperial with its brilliant unit steps (12, 16, 3, 5280, etc) and whomever the wanker was that decided US gallons should be different just because....
You are conflating two separate issues: the base used for calculations and numbering and the units used for measuring. The people who claim base 10 is bad point to the fact that it is only integer divisible by 2 and 5, often suggesting that 12 would be 'better' (integer divisible by 2,3,4, and 6). 10 probably won out for no reason better than the fact that most of us have 10 terminal appendages on our two upper limbs. The imperial system of measurements 'just grew', without any requirement for consistency or logic, though the fact that many of its components allow division of a larger unit into many different integral (for the next smaller unit) parts is probably not an accident. As for the difference between the 'actual' size of US and imperial pints (both system's gallons comprise eight of their respective pints), I share your dismay!

bjtheone
Posts: 1304
Joined: Mon May 20, 2019 11:28 pm
Location: The Frozen North (AKA Canada)

Re: knots to km/h

Fri May 07, 2021 7:18 pm

pfletch101 wrote:
Fri May 07, 2021 6:10 pm
bjtheone wrote:
Fri May 07, 2021 5:39 pm
I am not sure how you can claim base 10 is bad, when the other choice is imperial with its brilliant unit steps (12, 16, 3, 5280, etc) and whomever the wanker was that decided US gallons should be different just because....
You are conflating two separate issues: the base used for calculations and numbering and the units used for measuring. The people who claim base 10 is bad point to the fact that it is only integer divisible by 2 and 5, often suggesting that 12 would be 'better' (integer divisible by 2,3,4, and 6).
Nope I was potentially misunderstanding Heater's use of "base". One of the most broken thing about the imperial system is the absolutely bizarre number of units and their odd relationships. You cannot infer anything by the names, and the relationships are all different. With metric things step by factors of 10 and the relationship between units of the same measure are defined by the prefix. I would argue that that makes it a rational base 10 system.

The pints thing is just another way America took a deeply flawed system and made it worse, plus 354 ml is not a appropriate serving size for beer, and 473 ml is just a scam, to yield 5% more in the bottling.

Heater
Posts: 18261
Joined: Tue Jul 17, 2012 3:02 pm

Re: knots to km/h

Fri May 07, 2021 9:07 pm

bjtheone wrote:
Fri May 07, 2021 5:39 pm
Even as a child of imperial, and still not being able to visualize in dimensions in metric, I have to concede is a much much better system than imperial.
Why?
bjtheone wrote:
Fri May 07, 2021 5:39 pm
I am not sure how you can claim base 10 is bad, when the other choice is imperial with its brilliant unit steps (12, 16, 3, 5280, etc) and whomever the wanker was that decided US gallons should be different just because....
At first sight it might seem that choice of number base does not really matter much. Base 7 would work. So would base 39. Or whatever. What difference could it make? Let's just pick one and use that.

We are sold on the idea that base 10 is the sensible choice on the grounds that humans have 10 appendages on their hands. I don't really buy that reason. For example using my thumb as a "pointer" I can count to 12 on the bones in my fingers on one hand.

Consider this:

In the so called metric/base 10 world we now live in I can buy a box of 10 eggs. All that makes sense we are in a base 10 world right.

But if I don't need so many eggs, say I only need half as many, the next size down is 6.

WTF? Where did that come from? That is not half of 10. That is not any nice base 10 number. Why not 5 like it should be?

Well, of course it could not be 5. That does not pack nicely into a rectangular box. No body would do that.

If you ponder these things long enough you realise base 10 is very inconvenient for so many things. Base 12 would be better.

10 can only be nicely divided into piles of 2 or 5. Where as 12 can be nicely divided into piles of 2, 3, 4, 6. Notice how some of those piles will pack neatly into a rectangular box. All in all giving much more choice of easy ways to do things.

Why in this base 10 world, am I currently sucking on a one third litre can of beer? One third cannot even be completely specified in decimal notation. How crazy is that?

For an interesting look at why decimal is stupid and a base like 12 would be much more convenient do check out
Lindybeige's wonderful presentation on "Pounds, shillings, and pence: a history of English coinage" : https://www.youtube.com/watch?v=R2paSGQRwvo

Apparently this really clicks with mathematicians when it is pointed out to them. They see the utility in it. Everyone else just blindly uses base 10 as best they can without thinking about it much.
Memory in C++ is a leaky abstraction .

User avatar
Gavinmc42
Posts: 5702
Joined: Wed Aug 28, 2013 3:31 am

Re: knots to km/h

Fri May 07, 2021 11:18 pm

Base 60 is even better
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

pidd
Posts: 2101
Joined: Fri May 29, 2020 8:29 pm
Location: Wirral, UK
Contact: Website

Re: knots to km/h

Sat May 08, 2021 1:53 am

Gavinmc42 wrote:
Fri May 07, 2021 11:18 pm
Base 60 is even better
Babylonians beat us to it, the problem is for kids its difficult to learn all the names and symbols.

The biggest problem with a large radix is that simple addition and subtraction become crazily difficult, you would have to remember 1800 results. There are ways around this with clever notation that can allow a sub-radix (like the way hex can be broken down to octel) but then you wouldn't really be in base 60 (which is what the Babylonians did)..

Return to “General discussion”