Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NSD to trajectory calculation #280

Open
walljcg opened this issue Oct 4, 2024 · 0 comments
Open

Add NSD to trajectory calculation #280

walljcg opened this issue Oct 4, 2024 · 0 comments
Assignees

Comments

@walljcg
Copy link
Collaborator

walljcg commented Oct 4, 2024

I think we used to have this but seems to have been dropped. Would like to add the Net-Square Displacement calculation when we generate a trajectory. The basis for the logic is here:

def calculate_nsd(traj):
    def calculate_nsd(group):
        first_point = group.geometry.iloc[0]
        group['nsd'] = group.geometry.apply(lambda point: 
             point.distance(first_point) ** 2)
        return group

    nsd_df = traj.groupby('groupby_col').apply(calculate_nsd)
return nsd_df

Note that this one of those calculations where it only makes sense in the context of a single subject's dataset and not across multiple subjects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants