I am new to Geopy. I am working in this transportation company and need to get the total kilometers that a truck has operated.
I have seen some answers here but they did not work for me.
I have the following Dataframe from a GPS installed on the truck
latitude longitude
0 -25.145439 -54.294871
1 -24.144564 -54.240094
2 -24.142564 -54.198901
3 -24.140093 52.119021
The first step is making a third column tranforming everything to a point but all of my attempts failed
I write
df['point'] = df['latitude'].astype(float),df['longitude'].astype(float)
It returns an object. I would like it to return a point. My obective is to have:
latitude longitude Point
0 -25.145439 -54.294871 (-25.145439 -54.294871)
1 -24.144564 -54.240094 (-24.144564 -54.240094)
2 -24.142564 -54.198901 (-24.142564 -54.198901)
3 -24.140093 52.119021 (-24.140093 52.119021)
Then I would like to make the distance from these two so I would have something like this:
latitude longitude Point Distance KM
0 -25.145439 -54.294871 (-25.145439 -54.294871) 0
1 -24.144564 -54.240094 (-24.144564 -54.240094) 0,2
2 -24.142564 -54.198901 (-24.142564 -54.198901) 0,4
3 -24.140093 52.119021 (-24.140093 52.119021) 0,2
Note the the distance is the difference from the row above (it is already in order)
I am trying:
df['distance'] = geodesic(df['point'],df['point'].shift(1))
And I am getting an error that it does not work with tupple.
Anyone knows a solution for this?
tks