jmsigner / amt

37 stars 13 forks source link

Error when running hr_kde #30

Closed bniebuhr closed 4 years ago

bniebuhr commented 4 years ago

Hello,

I am trying to calculate KDE, AKDE and other estimates using the approach presented in Signer and Fieberg pre-print (home range in a tidy world). It is a very nice approach, thanks for that!

However, I am having some trouble when running hr_kde or hr_akde. I get the following error for both:

kde1 <- hr_kde(mov.track.1, levels = c(0.5, 0.95))
Error in sp::CRS(SRS_string = from$wkt) : 
  unused argument (SRS_string = from$wkt)

May it be because of the CRS I am using?

I don't know exactly how to make a reprex out of it, but I can send a piece of code and data to you guys, if it is the best way. Here a sample of my code:

library(tidyverse)
library(amt)
library(sf)

# Load data
movement_data <- read_rds("data/movement_data.rda")

# crs to use
crs.use <- sp::CRS("+proj=aea +lat_1=-5 +lat_2=-42 +lat_0=-32 +lon_0=-60 +x_0=0 +y_0=0 +ellps=aust_SA +units=m")

# transform data into track object
mov.track <- movement_data %>% 
  amt::make_track(X, Y, timestamp, ID, name, sex, weight.kg, estimated.age.months,
                phase, crs = sp::CRS("+init=epsg:4326")) %>% 
                amt::transform_coords(crs_to = crs.use)

# select 1 individual
mov.track.1 <- mov.track %>% 
  dplyr::filter(name == "Jussara")

# calculate MCP and KDE
mcp1 <- hr_mcp(mov.track.1, levels = c(0.5, 0.95))
kde1 <- hr_kde(mov.track.1, levels = c(0.5, 0.95))

Any hints on why this may happen? Thanks!

PS: below my session Info

R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
 [1] ggeffects_0.14.3   broom_0.5.3        sf_0.9-6           amt_0.1.3          ggpubr_0.2.4      
 [6] magrittr_1.5       lubridate_1.7.4    forcats_0.4.0      stringr_1.4.0      dplyr_1.0.2       
[11] purrr_0.3.3        readr_1.3.1        tidyr_1.0.0        tibble_2.1.3       ggplot2_3.3.2     
[16] tidyverse_1.3.0    knitr_1.26         ezknitr_0.6        install.load_1.2.1

loaded via a namespace (and not attached):
 [1] nlme_3.1-140        fs_1.3.1            insight_0.8.5       httr_1.4.1          rprojroot_1.3-2    
 [6] numDeriv_2016.8-1.1 tools_3.6.1         backports_1.1.5     utf8_1.1.4          rgdal_1.4-8        
[11] R6_2.4.1            sjlabelled_1.1.5    KernSmooth_2.23-15  rgeos_0.5-2         DBI_1.1.0          
[16] colorspace_1.4-1    raster_3.0-7        withr_2.1.2         sp_1.3-2            tidyselect_1.1.0   
[21] compiler_3.6.1      cli_2.0.1           rvest_0.3.5         xml2_1.3.2          scales_1.1.0       
[26] checkmate_1.9.4     DEoptimR_1.0-8      robustbase_0.93-5   classInt_0.4-2      mvtnorm_1.0-11     
[31] minqa_1.2.4         pkgconfig_2.0.3     lme4_1.1-21         bibtex_0.4.2.2      dbplyr_1.4.2       
[36] bbmle_1.0.22        rlang_0.4.7         readxl_1.3.1        rstudioapi_0.10     FNN_1.1.3          
[41] generics_0.0.2      jsonlite_1.6        Gmedian_1.2.4       Matrix_1.2-17       Rcpp_1.0.3         
[46] munsell_0.5.0       fansi_0.4.1         lifecycle_0.2.0     stringi_1.4.3       gbRd_0.4-11        
[51] MASS_7.3-51.4       grid_3.6.1          bdsmatrix_1.3-3     crayon_1.3.4        lattice_0.20-38    
[56] haven_2.2.0         splines_3.6.1       hms_0.5.2           pillar_1.4.3        boot_1.3-22        
[61] ggsignif_0.6.0      ctmm_0.5.7          codetools_0.2-16    stats4_3.6.1        reprex_0.3.0       
[66] glue_1.4.2          packrat_0.5.0       modelr_0.1.5        vctrs_0.3.4         nloptr_1.2.1       
[71] Rdpack_0.11-1       cellranger_1.1.0    gtable_0.3.0        assertthat_0.2.1    xfun_0.12          
[76] lwgeom_0.2-5        RSpectra_0.16-0     e1071_1.7-3         class_7.3-15        survival_3.1-8     
[81] units_0.6-5         ellipsis_0.3.0  
bniebuhr commented 4 years ago

Sorry, I just solved it by updating the sp package. Sorry for that!