Distance between two latitude longitude can be calculated by installing geopy in python. First we have to install geopy using command

pip install geopy
from geopy.distance import geodesic,great_circle,distance
a=(lat,lon)
b=(lat,lon)
print(geodesic(a, b).m) # will output  distance in meter
print(great_circle(a, b).km) # will output  distance in kilometer
#we can also calculate distance using distance module
print(distance(a,b).m)

Now suppose we have CSV file(approx. 13 entries) in which we have given latitude and longitude we have to calculate distance between these lat long.

csv file format as shown in image for calculating Distance between two latitude longitude
CSV file format
import csv
c=[]
with open('loc.csv') as f:
csvFile = csv.reader(f)
for lines in csvFile:
c.append(lines)
i=1
while i<len(c):
print(geodesic(eval(c[i][0]),eval(c[i][1])).km)
i+=1

Output: It will give output distance between kilometers.

931.1817581240865
945.5758084468735
898.3501672127177
911.3711029573434
948.7617076719985
893.6839515361726
902.0774166947069
896.059565161947
901.3731291898005
893.3135775485226
895.9457613508412
904.3414826188593
892.5157807369251
895.1791669102521
906.6234116443412
906.7213944944685
900.4152026741061
895.0616213300677
890.9994531181933
940.7633232129197
957.8471949241856
949.374224094599
1006.0602665540223
952.2150475661487
1007.792682505535
1010.1194430411483
953.3076639415609
950.269847247922
1006.4740278921582
938.5565285627673
988.192617601689
979.1393016844975
982.4110485534795
762.0948493166107
743.3115913349499
789.855395877816
788.9260886077299
793.4489773743286
781.5121088141493
784.3420199810138
764.8202055015702
773.0121570415629
770.6204655279435
876.2250096321861
814.2116036337206
810.5617581236705
805.8960170806795
990.5736983914798
979.6585166368402
985.2503614720858
276.83186367335213
288.26569926567316
290.3116145989531
221.36979283080902
1040.2948986209892
1033.5073283855793
1032.4352612544449
1028.8524908335874
1037.87037587391
1038.0367759873357
1061.2178298106016
805.3129801986013
806.5937268098553
796.8842629594138
802.3647898084137
732.8031381142297
705.3936717352212
732.5494190343012
1090.4411693227362
849.8664523999399
887.2891073022854
882.488936499881
894.751138689188
884.469267983296
979.358170285383
977.9427920308186
824.2633486547899
824.2534024661735
832.7872887935674
833.5997891562406
837.3085692151963
828.9632079549685
800.9701832431276
799.4033996835163
980.48855116572
982.1132140018188
981.834099428116
1088.335044927968
1077.4298271708344
1086.707251137461
1092.959757980318
1071.529009940923
1066.5534421828995
1070.42912200321
1054.372567622125
1051.0789823499963
1066.2066548621767
1064.0374511286284
968.2127961529596
1056.6513220247202
1058.5113871001126
1053.79051974116
961.4609419341934
966.6477404647725
196.2851424425836
193.38602755091128
197.29932586493697
194.06503129620936
250.8190722689174
266.29894819760256
144.96745766711942
144.9543047778915
146.09733226197562
145.08041326888198
147.043929166707
146.61577895137253
142.84104351459496
147.483608926255
235.78935612846865
234.88545293062828
236.7549628761842
248.72694732407575
223.04796489536278
145.34839680827452
172.86187873443455
169.6041762847654
175.47374917048325
306.63270024624376
194.97480593186145
194.74882571658577

https://distancebwlatlong.streamlit.app/

Click on above link to calculate distance between two latitude longitude.

By SC

Leave a Reply

Your email address will not be published. Required fields are marked *