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

Incorrect number of dimensions error with prt_trim() #27

Open
Miguelbirostris opened this issue Nov 14, 2023 · 3 comments
Open

Incorrect number of dimensions error with prt_trim() #27

Miguelbirostris opened this issue Nov 14, 2023 · 3 comments
Assignees

Comments

@Miguelbirostris
Copy link

Hi!
I am working around a satelite tracking dataset in which several of the last points en up over and (an animal moving closely to the coastline). I jave tried to apply prt_trim() as suggested by pathroutr, but I am etting this error.

class(track_pts)
[1] "sfc_MULTIPOINT" "sfc"
class(ns_polygon)
[1] "sf" "data.frame"
track_pts_fix<-prt_trim(track_pts,ns_polygon)
Error in [.default(trkpts, head_start:tail_end, ) :
Incorrect number of dimensions

Any workaround?

@jmlondon jmlondon self-assigned this Nov 14, 2023
@mfutia
Copy link

mfutia commented Nov 16, 2023

I was able to resolve this by removing a comma in the prt_trim() function using the trace function.

trace(track_pts, edit = T)

Then on line 22 of the trace (42 of the function file) remove the comma within brackets

trkpts <- trkpts[head_start:tail_end,] #Comma at the end of this line 

@jdpye
Copy link

jdpye commented Nov 16, 2023

There may be times where that trailing comma is appropriate, but i think posting a sample of the source datasets here could help us tease out a version of this function that handles those cases but also your cases in a sensible way.

@jmlondon
Copy link
Owner

@Miguelbirostris thank you for posting this Issue. And, thank you to @mfutia and @jdpye for your comments.

I'm fairly certain that 'comma' is a typo ... but, need some time to double check with some sample data. So, if you can share a small dataset as part of a regex, that would be helpful as an additional check.

I suspect there are still some older/naive 'less than best' coding practices sprinkled throughout pathroutr with respect to some of the dplyr/purrr functions underneath. This could also be one of those situations.

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

4 participants