uh hello guys welcome to this video so
in this video I will show you how to
calculate the distance between two
locations inside Python with a free
module called as gopy
uh which contains a method to calculate
the distance between two locations so
first of all you need to install this
module so pip install gopy i've already
installed this module so now after
installing it we written this simple
script we provide the location one
latitude and longitude and location two
latitude and longitude and then we
calculate the distance between these two
locations so if I try to run this Python
script you will see it will provide you
with a distance which is in kilometer
58553.10
kilometer so this is your stat statue of
liberty and this is your eel tower
so so I will show you how to initialize
this so first of all using this module
free module it contains this distance
class we need to import this and here we
need to specify the location one
latitude and longitude so latitude and
longitude are nothing but the locations
or coordinates that you specify while
plotting locations on a Google map so
these are used in plotting on a physical
map so here we are providing these
latitude and longitudes and then after
that we need to calculate the distance
between them so this provides you with a
simple
method so here we specify these two
locations location one comma location
two and then it has this
uh kilometers property so it will
provide you with the distance how much
distance is there so here you can simply
print out the distance like
this
so it's a very handy module guys you can
see distance between two locations is
that
so we can even convert this let's
suppose you only want to write the two
locations you can use chat GPT here so I
will say just convert the
script so that I don't want to
provide latitude and longitude
we just want to write city names so I'm
just asking chart GPT so that we can
instead we can write city names instead
of writing the latitude and longitude so
it has given me this script here if I
paste the script so instead providing
the latitude and longitude now we
providing two city names you can see
this is the city one this is city 2 and
then it does the same thing if I run
this script now you will
see you first of all need to initialize
this so you will see distance between
New York New York City and Paris is
58560 kilometer so in this easy
way now instead of providing latitude
and longitude we provided two cities
city one city 2 and then first of all we
convert this into the latitude and
longitude for this we use geocoding
method for this this module is a very
handy module it provides you with this
method which is geocode so we convert
these physical locations into latitude
and longitude by using this method after
we get this latitude and longitude we
store it inside these two variables and
then we actually provide the kilometers
we again use the same method geo
description we provide these two
locations and then we simply print the
location uh distance between two these
two
cities and you can cross verify as well
so if I say distance
between New York City and
Paris so it's
3625 I will say in
kilometer 58 33 kilometer so again this
script is also returning the same result
it's round about the same here which is
5850 google is telling me it is 5833
it's round about the same so we can
change the locations here let's suppose
I say I want to dis Sydney to
Oakuckland so I've given the script guys
in the description of the video if you
need the script you can go to my website
and copy paste the script it's very
simple the nice part is that it's
completely free you don't need any sort
of API key you simply uh replace the
locations and then it will tell you the
distance between the two locations so
you can see that so thank you very much
guys for watching this video and also
check out my website freemediattools.com
uh which contains thousands of tools