0
First, I have 2 dataframe with several latitude and longitude points:
db_gas2['lat-long'] = db_gas2['latitude'].astype(str)+', '+db_gas2['longitude']
db_gas2
db_cidades3['lat-long'] = db_cidades3['latitude'].astype(str)+', '+db_cidades3['longitude']
db_cidades3.head()
db_gas2 has 37 lines (which are local)
db_cidades3 has 5,570 lines (municipalities of Brazil)
I managed to create this in a simulator, but not one for i range
#teste se a variavel "ponto gás" iria funcionar
ponto_gas = 1
# range de 0 a 36
cidade_origem = 1050
# range de 0 a 5569
p1 = (db_cidades3.iloc[cidade_origem]['lat-long'])
p1_n = (db_cidades3.iloc[cidade_origem]['cidade'])
p2 = (db_gas2.iloc[ponto_gas]['lat-long'])
p2_n = (db_gas2.iloc[ponto_gas]['Ponto de entrega'])
print("A distância entre a cidade", p1_n, "e o ponto de entrega", p2_n, "é de:")
print(round((distance.distance(p1, p2).km),2),"km")
The answer comes true "The distance between the city of Teixeiras and the TBG Bilac delivery point is: 794.22 km"
However, how to do it for each municipality is calculated the distance for the 37 gas lines. I want to automatically take line 1 of "db_city3" and calculate distance for all lines of "db_gas2", after that take line 2 of "db_city3" and calculate distance for all lines of "db_gas2" ...
Can you help me?