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

The first two points has distance larger than dist_threshold will be considered as staypoint. #615

Closed zrg1993 closed 5 months ago

zrg1993 commented 5 months ago

For example, there are three points like [point1, point2, point3].

Whendistance(point1, point2) > dist_threshold, and the time_threshold also satisfies the condition.

The first two points[point1, point2]will be considered as statypoint.

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

bifbof commented 5 months ago

Hello there, thank you for opening an issue. As for your example:

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

If that answered your question, please let me know. Otherwise, it would be really helpful if you could state your issue with the code and provide an minimal code example that produces said issue. (Then maybe @hongyeehh could help?)

zrg1993 commented 5 months ago

@bifbof Thank you for the response. Here is the data I am using for test. I just set the different longitude and time for each point.

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

And the staypoints result is :

image

I am wondering that the staypoint does have the started_at and finished_at. The test case output above on started_at and finished_at will have conflict with the staypoint geometry. The output I except will be the final two points:

started_at : point2
finished_at : point3

Looking forward to your reply. Thanks.

hongyeehh commented 5 months ago

Hi, I think the issue is regarding the time and geometry assignment of staypoints:

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

Let me know if that clarifies the issue

zrg1993 commented 5 months ago

@hongyeehh Thanks for your reply. Would you like to check the output I uploaded again? The started_at and finished_at timestamp are including the trip distance exceed the dist_threshold parameter. The conflict I am meaning is the started_at and finished_at is not the correct output on the sample data.

I found a lot of implementations of Li et al. (2008) paper did not consider the case I mentioned. Would you like to check the logic on the first two points in the sample data above again?

hongyeehh commented 5 months ago

I am trying to understand the issue.

Do you anticipate two staypoints being generated based on the sample data you provided? One is shown in your screenshot, and the other is from points 2 to 3.

You can pass include_last=True, so the function will consider/aggregate pfs at the end of the tracking.

zrg1993 commented 5 months ago

@hongyeehh Thanks for your advice. And I draw the image of current output which should not been considered as one staypoint no matter include_last is set to True or False. image

hongyeehh commented 5 months ago

I am afraid I do not understand the issue. Please open a new issue with the bug template if you think the bug persists.

zrg1993 commented 5 months ago

The question is if the distance between point1 and point2( e.g. point1 : Tokyo, point2 : Beijing) is larger than dist_threshold and the time difference is larger than time_threshold, the output will regard the point1 and point2 as one stay.

hongyeehh commented 5 months ago

@bifbof Thank you for the response. Here is the data I am using for test. I just set the different longitude and time for each point.

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

And the staypoints result is : image

I am wondering that the staypoint does have the started_at and finished_at. The test case output above on started_at and finished_at will have conflict with the staypoint geometry. The output I except will be the final two points:

started_at : point2
finished_at : point3

Looking forward to your reply. Thanks.

From your provided demo, the staypoint is only formed from Point 1. Point 2 is thus the first point outside this staypoint.

zrg1993 commented 5 months ago

@hongyeehh Thank you very much. I understand the finished_at meaning now.