diff --git a/DESCRIPTION b/DESCRIPTION index 6e637177..40885967 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: camtraptor Title: Read, Explore and Visualize Camera Trap Data Packages -Version: 0.21.0 +Version: 0.22.0 Authors@R: c( person("Damiano", "Oldoni", email = "damiano.oldoni@inbo.be", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-3445-7562")), diff --git a/NEWS.md b/NEWS.md index d832c816..a5192b3c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# camtraptor 0.22.0 + +- Fix bug in `write_eml()` for Camtrap DP 1.0 datasets (#290). +- `read_camtrap_dp()` will now always populate `taxonID` from the + `package.taxonomy` (#290). + # camtraptor 0.21.0 - `read_camtrap_dp()` supports Camtrap DP 1.0 (upcoming Agouti export format) diff --git a/R/write_eml.R b/R/write_eml.R index bb2a1ad4..a7d9b036 100644 --- a/R/write_eml.R +++ b/R/write_eml.R @@ -167,10 +167,7 @@ write_eml <- function(package, ) } # Sort contributors on order in creators - contributors <- dplyr::slice( - contributors, - order_by = order(factor(.data$title, levels = creators)) - ) + contributors <- arrange(contributors, factor(title, level = creators)) } creator_list <- purrr::transpose(contributors) # Create list message(glue::glue( diff --git a/R/zzz.R b/R/zzz.R index d4d3f075..9f40e361 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -367,19 +367,25 @@ add_taxonomic_info <- function(package) { taxon_infos <- dplyr::select( taxon_infos, dplyr::all_of("scientificName"), - dplyr::any_of(c("taxonIDReference", - "taxonRank")), + dplyr::any_of(c("taxonID", "taxonIDReference", "taxonRank")), dplyr::starts_with("vernacularNames") ) - # add taxon infos to observations + # Add taxon infos to observations if (!is.null(taxon_infos)) { cols_taxon_infos <- names(taxon_infos) observations <- dplyr::left_join( package$data$observations, taxon_infos, - by = c("scientificName") + by = "scientificName" ) + if ("taxonID.y" %in% colnames(observations)) { + # Keep only the taxonID added by join with taxonomy + observations <- + observations %>% + rename("taxonID" = "taxonID.y") %>% + select(-"taxonID.x") + } package$data$observations <- observations } return(package) @@ -497,7 +503,8 @@ convert_metadata_to_0.1.6 <- function(package, from = "1.0"){ "The field `sequenceInterval` is deprecated in version {from}." )) } - package$platform <- package$sources[[1]]$title + package$platform <- package$sources[[1]] + # `title` value of the first contributor with role `rightsHolder` package$rightsHolder <- purrr::map_df(package$contributors, unlist) %>% dplyr::filter(.data$role == "rightsHolder") %>%