Regarding problem with appending species name

66 views
Skip to first unread message

Sanath R M

unread,
Apr 29, 2023, 10:43:17 AM4/29/23
to camtrapR
Hello everyone, 
I am new to CamtrapR, and I am trying to append species names to the images, but getting this error, which I couldn't resolve on my own.
 Error in if (metadata.tmp == "found no species tag") { :
the condition has length > 1

I am pasting the code here, as well as the image of the record table.

code is as follows
#append species names to images

species_name_append<-appendSpeciesNames(inDir ="F:/Camera trap/Try2/CT copy/CT renamed", IDfrom="metadata", hasCameraFolders = FALSE ,metadataSpeciesTag ="Mammal", removeNames = F,metadataHierarchyDelimitor="|",writecsv = TRUE)

#record table

length(list.files(wd_image_renamed, pattern = "JPG", recursive = TRUE))
rec.db.species0 <- recordTable(inDir = wd_image_renamed,
                               IDfrom = "metadata", metadataSpeciesTag = "Mammal", minDeltaTime = 0,removeDuplicateRecords = F, writecsv = T)




Picture1.png

Juergen Niedballa

unread,
May 18, 2023, 2:36:48 AM5/18/23
to camtrapR
Hello,
does this happen in the current GitHu version? If yes it may be a bug. Feel free to share a reproducible example (a few images and the code will do, as long as it creates the error message).
Thank you,
Jürgen

Sanath R M

unread,
May 19, 2023, 3:38:06 AM5/19/23
to camtrapR
Thanks, Juergen, installed the current GitHub version and it resolved the issue.
I have one more small issue; when I try to copy species images to folders, it works fine for single species, but when I try to copy multiple species images together, I am getting an error.

wd_images_species_copy<-file.path("F:/Camera trap/Camera Trap Data/2023PreMon working folder/2023PreMonSpecies")
> species_to_copy <- c("Barking Deer")
> recordtable<-read.csv("F:/Camera trap/Camera Trap Data/2023PreMon working folder/2023PreMonrRenamed/record_table_0min_deltaT_2023-05-19.csv")
> specImagecopy <- getSpeciesImages(species = species_to_copy, recordTable=rec.db.species0, speciesCol="metadata_Mammal", stationCol="Station", outDir = wd_images_species_copy, createStationSubfolders = FALSE )
BARKING DEER  - copied 316 out of 316 images to   F:/Camera trap/Camera Trap Data/2023PreMon working folder/2023PreMonSpecies/Barking Deer

But on trying multiple species its giving me an error

wd_images_species_copy<-file.path("F:/Camera trap/Camera Trap Data/2023PreMon working folder/2023PreMonSpecies")
> species_to_copy <- c("Barking Deer","Bonnet Macaque","Brown Mongoose","Brown Palm Civet","Common Langur","Elephant","Gaur","Leopard Cat","Mouse Deer","Nilgiri Marten","Other","Sambar","Small Indian Civet","Wild Pig")
> recordtable<-read.csv("F:/Camera trap/Camera Trap Data/2023PreMon working folder/2023PreMonrRenamed/record_table_0min_deltaT_2023-05-19.csv")
> specImagecopy <- getSpeciesImages(species = species_to_copy, recordTable=rec.db.species0, speciesCol="metadata_Mammal", stationCol="Station", outDir = wd_images_species_copy, createStationSubfolders = FALSE )
Error in if (species %in% recordTable[, speciesCol] == FALSE) stop("species was not found in speciesCol of recordTable",  :
  the condition has length > 1

Juergen Niedballa

unread,
Jun 28, 2023, 7:59:50 AM6/28/23
to camtrapR
That is correct, it only works on individual species. You can for example use sapply() / lapply() or a loop to run it for multiple species.

Floriely CC

unread,
Sep 9, 2023, 4:07:27 AM9/9/23
to camtrapR
Hello, I am new to camtrapr. I have the same error as Sanath´s, but I using the lastest version of R and the lastest version of camtrapR. How can i solve this error?


fotos_especies <- appendSpeciesNames(inDir = fotos_proyecto20,
+ IDfrom = "metadata", + hasCameraFolders = F, + metadataSpeciesTag = "Species", + removeNames = F) Error in if (metadata.tmp == "found no species tag") { : the condition has length > 1
Reply all
Reply to author
Forward
0 new messages