mie-lab / trackintel

trackintel is a framework for spatio-temporal analysis of movement trajectory and mobility data.
MIT License
198 stars 50 forks source link

For the case that the first two point are staypoints, the output will be wrong. #616

Closed zrg1993 closed 5 months ago

zrg1993 commented 5 months ago

Here is the test data I am using. I just set the first two points are near to each other and I expect they should be recognized as staypoints.

lat,lon,elevation,time,User,geometry
39.98470,115.31842,149.9616,"2008-10-23 02:45:04+00:00",0,"POINT (115.31842 39.98470)"
39.98470,115.31843,149.9616,"2008-10-23 02:59:04+00:00",0,"POINT (115.31843 39.98470)"
39.98470,116.31842,149.9616,"2008-10-23 03:45:04+00:00",0,"POINT (116.31842 39.98470)"

However, the algorithm did not return the output as I expected. I found the reason is the line below. The reason is the comparison between the original row and the pandas shift function output on the first row will ignore the difference and just regard the difference as false.

https://github.com/mie-lab/trackintel/blob/0cc1782b6e48ba52f9aac63a8b13822e67da1aa5/trackintel/preprocessing/positionfixes.py#L481

Looking forward to your reply.

hongyeehh commented 5 months ago

Hi,

Can you provide the parameters you use for running the generate_staypoints() function? The first two rows have 15-minute intervals, which might exceed the gap_threshold parameter, thus regarded as a time gap and not be recognized as one staypoint.

zrg1993 commented 5 months ago

@hongyeehh Thank you for your reply. I used the default parameters in the generate_staypoints()function. The default gap_threshold parameter is 15.0 mins. And the time gap between the first two points is 14.0 mins in the sample data above.

Would you like to have a try on your local environment using the sample data above?

hongyeehh commented 5 months ago

The reason why no staypoint is generated is that the gap between the 2nd and 3rd pfs is larger than gap_threshold. You need to increase the gap_threshold parameter (which implies that you assume the user is stationary during the 2nd-3rd pfs).

The resulting staypoint will start at the 1st and end at the 3rd timestamp.

zrg1993 commented 5 months ago

My question have no relation with the trip between point2 and point3. I am not expecting the point2 and point3 three as staypoint at all. My problem is the point 1 and point 2 should be one staypoint because they satisfy the options on all the parameter. However, the output of staypoint from trackintel is None.

hongyeehh commented 5 months ago

Yes, I understand your question.

However, whether points 1 and 2 will form a staypoint will depend on the 3rd point because of our temporal gap consideration; see discussion #615 and this code line