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

Fix utm_convert() #148

Merged
merged 6 commits into from
Nov 29, 2024
Merged

Fix utm_convert() #148

merged 6 commits into from
Nov 29, 2024

Conversation

ateucher
Copy link
Collaborator

@ateucher ateucher commented Nov 28, 2024

This ensures that the output of utm_convert() is the same as the input, except with the new spatial information.

There were two main issues:

  1. split() was splitting on a numeric column and thus was ordering the split sub data frames on that numeric, rather than respecting the order they were in in the original data.frame.
  2. We were cbind()ing unnecessarily in the reassembled data frame, because that could have been (and is now) delegated to convert_from_zone() as it is run on each individual sub-dataframe separately.

The cbinding of the original data frame with the reassembled sub data frames (which were reassembled not in order) resulted in a mismatch of rows.

Now in each sub data frame we keep the input columns, and cbind X and Y if they are asked for, then reassemble the sub-dataframes, in the order they were in in the orginal input.

Finally, if an input was a tibble, it is now returned as a tibble.

Closes #146; closes #143

* restore original class
* Supply character vector to `split` to ensure order remains the same
* Less cbind()ing
Copy link
Member

@stephhazlitt stephhazlitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ateucher!

Copy link
Collaborator

@boshek boshek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ateucher ateucher merged commit eb3d236 into main Nov 29, 2024
6 checks passed
@ateucher ateucher deleted the fix-utm_convert branch November 29, 2024 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants