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

error in frames_spatial() when creating frames for more than 20 tracks #113

Open
makratofil opened this issue Jan 3, 2023 · 2 comments
Open

Comments

@makratofil
Copy link

This is going to sound crazy but I haven't been able to source any solution yet. I'm having issues creating spatial frames for MoveStack objects that contain more than 20 animal tracks: Error in if (row1 == 1 & row2 == nrow(x) & col1 == 1 & col2 == ncol(x)) { : missing value where TRUE/FALSE needed.

My code for this worked successfully not too long ago, and I'm able to create spatial frames via frames_spatial() with subsets that include fewer tracks using the exact same code but for some reason not the sets with 21+. I copied the code and output below, but can connect via email if you need some of the data I'm working with (or could try with large dataset from Movebank?).

frames_hap <- frames_spatial(m, path_colours = col12CBx2,
                             map_service = "esri", map_type = "world_imagery",
                             equidistant = F,
                             path_fade = TRUE, 
                             tail_length = 12,
                             path_legend = F,
                             path_join = "mitre")

Checking temporal alignment...
Processing movement data...
Approximated animation duration: ≈ 16s at 25 fps for 400 frames
Retrieving and compositing basemap imagery...
Loading basemap 'world_imagery' from map service 'esri'...
|===============================================================================================================| 100% elapsed=02s
Assigning raster maps to frames...
Error in if (row1 == 1 & row2 == nrow(x) & col1 == 1 & col2 == ncol(x)) { :
missing value where TRUE/FALSE needed

The m object is a MoveStack object of 21 tracks and the col12CBx2 vector is just a vector of 21 colors, one for each track. Again, this exact script works just fine for subsets of the original data that include 20 or fewer tracks (with the corresponding number of path colors).

Session info:

R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] lubridate_1.9.0  timechange_0.1.1 move_4.1.10      rgdal_1.5-32     raster_3.6-3     sp_1.4-7         geosphere_1.5-14 ggplot2_3.3.6   
 [9] dplyr_1.0.9      moveVis_0.10.6  

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.0   terra_1.6-17       purrr_0.3.4        pbapply_1.5-0      sf_1.0-7           lattice_0.20-45    colorspace_2.0-3  
 [8] vctrs_0.5.0        generics_0.1.2     utf8_1.2.2         rlang_1.0.6        e1071_1.7-9        pillar_1.7.0       withr_2.5.0       
[15] glue_1.6.2         DBI_1.1.2          slippymath_0.3.1   av_0.8.2           lifecycle_1.0.3    munsell_0.5.0      gtable_0.3.0      
[22] basemaps_0.0.5     codetools_0.2-18   memoise_2.0.1      fastmap_1.1.0      parallel_4.2.0     curl_4.3.2         class_7.3-20      
[29] fansi_1.0.3        gifski_1.6.6-1     Rcpp_1.0.8.3       KernSmooth_2.23-20 scales_1.2.0       classInt_0.4-3     lwgeom_0.2-8      
[36] cachem_1.0.6       magick_2.7.3       grid_4.2.0         cowplot_1.1.1      cli_3.3.0          tools_4.2.0        magrittr_2.0.3    
[43] proxy_0.4-26       tibble_3.1.7       crayon_1.5.1       pkgconfig_2.0.3    ellipsis_0.3.2     xml2_1.3.3         assertthat_0.2.1  
[50] httr_1.4.3         rstudioapi_0.13    R6_2.5.1           units_0.8-0        compiler_4.2.0    
@Qianru-liao
Copy link

I just met the same problem. And I fixed it after I set a coarser resolution (from 180 to 240) in the previous step:
m <- moveVis::align_move(data, res = 240, unit = "mins")

It seems like the error is caused by the NA value in temporal interpolation.

@smerker
Copy link

smerker commented Dec 7, 2023

Sometimes I get this error and sometimes I do not. It is unclear when it happens and when the NA appears or doesn't. More often I get a fatal R crash.

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

3 participants