Associating pfx IDs with the tpls IDs
ABUBAKR-ALBASHIR opened this issue · 1 comments
Hello Developers,
I am using Trackintel to analyse big GPS data for mobility.
My workflow is to read the GPS data from CSV or GeoDataFrame as pfx where each record has an ID, Lat, long and a timestamp.
Where the ID is the ID of the vehicle. then generate the stay points and the triplegs.
I would like to have all the tripleg have an ID associated with the pfx ID.
The problem now is the generated stay points doesn't associate the pfx ID (and may not all the pfx have staypoints) and consequently, the generated triplegs doesn't have the pfx IDs.
Is there is another workflow, fucntion within Trackintel allow may to have the pfx IDs assigned to the generated triplegs?
Thanks in advance.
Hey,
Thanks for using trackintel in your workflow. It is true that we only provide pfs-sp
and pfs-tpl
links (e.g., tripleg id associated with pfs) and not the other way around. But the tpls-pfs
link can be recovered in the following way, if I understand your workflow correctly:
- run
generate_staypoints()
and thengenerate_triplegs()
functions on your raw pfx, the resulting pfx shall contain the columntripleg_id
- use
pfx.groupby("tripleg_id").index.agg(list)
(assuming index is the ID of pfs) to generate tripleg_id and pfs_ids pairs. - use
pd.merge
orpd.join
to merge the above results with the generated triplegs via the tripleg ID.
The result is a list of pfs_ids per tripleg. Let me know if this helps.