trackintel icon indicating copy to clipboard operation
trackintel copied to clipboard

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

Open zrg1993 opened this issue 1 year ago • 2 comments

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

When distance(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

zrg1993 avatar Apr 08 '24 07:04 zrg1993

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

  • yes, point1 can be a staypoint, as in the linked paper staypoints are possible with only one measurement.
  • point2 is only a staypoint if the following measurements (positionfixes in trackintel terminology) exceed the distance threshold and the time threshold. And there if there is no larger gap, due to the following lines

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?)

bifbof avatar Apr 08 '24 14:04 bifbof

@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.

zrg1993 avatar Apr 08 '24 15:04 zrg1993

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

  • "geometry": sps receive the centroid of their consisting pfs.
  • time: started_at is the first pf's timestamp that belongs to the sp, and finished_at is the first pf outside the sp. This follows the original algorithm and is described in the notes section:

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

Let me know if that clarifies the issue

hongyeehh avatar Apr 11 '24 10:04 hongyeehh

@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?

zrg1993 avatar Apr 11 '24 13:04 zrg1993

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.

hongyeehh avatar Apr 12 '24 10:04 hongyeehh

@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

zrg1993 avatar Apr 12 '24 11:04 zrg1993

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

hongyeehh avatar Apr 12 '24 12:04 hongyeehh

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.

zrg1993 avatar Apr 13 '24 01:04 zrg1993

@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.

hongyeehh avatar Apr 14 '24 15:04 hongyeehh

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

zrg1993 avatar Apr 15 '24 01:04 zrg1993