I have consecutive GPS position data (latitude, longitude)
sampling at every second for every day. This data is from multiple train trips going different direction using Paris-Lyon train track.
I need to filter out only the data among these multiple trips which are lying between two stations Paris Gare de Lyon and Lyon Part Dieu. For example, I just need to filter out all the data between two GPS coordinates of Paris (48.844601, 2.373777)
to Lyon (45.760573, 4.860163)
stations out of multiple trips over this track.
timestamp train_id latitude longitude train_speed
2021-03-01 00:00:00 3086 48.843067 2.378110 20.18520
2021-03-01 00:00:00 2086 48.843067 2.378110 20.18520
2021-03-01 00:00:00 7073 48.837433 2.388602 0.18360
--- --- --- --- ---
2021-03-01 23:59:59 1041 48.726383 2.542348 156.86281
2021-03-01 23:59:59 5006 46.829850 4.492440 182.00002
2021-03-01 23:59:59 2086 46.829850 4.492440 182.00002
I used below method, but it cannot return only the data between Paris-Lyon
. Its returns me also Paris-Lyon-Marseilles
, Paris-Lyon-Toulouse
, etc as well.
paris_lat= 48.844601
paris_lon= 2.373777
lyon_lat= 45.760573
lyon_lon= 4.860163
# filtering lat,lon between Paris and Lyon which is not working
df= gps_data[(gps_data['latitude'].between(48.844601, 45.760573)) & (gps_data['longitude'].between(2.373777,4.860163))]
Any help on this regard will be highly appreciated.
Here is the sample datasets:
timestamp train_id latitude longitude
2021-03-01 06:18:30 10 48.826300 2.400840
2021-03-01 06:18:31 10 48.826324 2.400820
2021-03-01 06:18:32 10 48.826350 2.400800
2021-03-01 06:18:33 10 48.826378 2.400780
2021-03-01 06:18:34 10 48.826410 2.400758
2021-03-01 06:18:35 10 48.826440 2.400737
2021-03-01 06:18:36 10 48.826470 2.400717
2021-03-01 06:18:37 10 48.826508 2.400695
2021-03-01 07:43:17 10 48.826153 2.401872
2021-03-01 07:43:18 10 48.825980 2.402124
2021-03-01 07:43:19 10 48.825813 2.402382
2021-03-01 11:17:52 10 43.308040 5.388560
2021-03-01 11:17:53 10 43.308056 5.388590
2021-03-01 11:17:54 10 43.308067 5.388617
Output:
Need to filter the datasets with all the [latitude,longitude]
lies between GPS coordinates [48.844601,2.373777]
and [45.760573, 4.860163]
:
timestamp train_id latitude longitude
2021-03-01 06:18:30 10 48.826300 2.400840
2021-03-01 06:18:31 10 48.826324 2.400820
2021-03-01 06:18:32 10 48.826350 2.400800
2021-03-01 06:18:33 10 48.826378 2.400780
2021-03-01 06:18:34 10 48.826410 2.400758
2021-03-01 06:18:35 10 48.826440 2.400737
2021-03-01 06:18:36 10 48.826470 2.400717
2021-03-01 06:18:37 10 48.826508 2.400695
2021-03-01 07:43:17 10 48.826153 2.401872
2021-03-01 07:43:18 10 48.825980 2.402124
2021-03-01 07:43:19 10 48.825813 2.402382