Errors in Creating Spatial Detection History - Rowname mismatch & Failure to match some capture locations to detector sites

68 views
Skip to first unread message

tyler murray

unread,
Jul 27, 2020, 9:01:03 AM7/27/20
to camtrapR
Hi all,

I have run into some issues when attempting to create a detection history for Ocelot individuals in camtrapR using the spatialdetectionhisotry function.

The first issue was an error due to a mismatch in rownames of the camop matrix and CT-table. I determined that this was due to having sub-directories for the pair of camera within each station folder, therefore the rownames created in the camop matrix differed from the station IDs of the CTtable and individual record table. I was able to get around this by renaming the CTtable and ID record table station ID's to match that of camop (though I doubt this is the proper fix) and then ran into another error: 

Error in make.capthist(captures = sdh2, traps = secr.traps, fmt = "trapID",  : failed to match some capture locations to detector sites

Can anyone suggest where I might have gone wrong? All of the images were tagged with species and ID names using digikam, and image renaming, creating record tables and survey reports have gone smoothly thus far. Could this be due to how the camera sub-directories are arranged (each within a separate folder in the station folder) or poor labelling? I have attached my code for the camop matrix, ID table and detection history below. 

Thanks all!

camop_prob <- cameraOperation(CTtable = camdb,
                              stationCol = "Station",
                              cameraCol = "Camera_ID",
                              byCamera = TRUE,
                              setupCol = "Date_Deployed",
                              retrievalCol = "Date_Retrieved",
                              camerasIndependent = FALSE,
                              writecsv = TRUE,
                              hasProblems = TRUE,
                              dateFormat = "%d/%m/%y")

idRT <- recordTableIndividual(inDir= wd_images_renamed,
                      hasStationFolders = TRUE,
                      IDfrom = "metadata",
                      cameraID = "filename",
                      camerasIndependent = FALSE,
                      minDeltaTime = 15,
                      deltaTimeComparedTo = "lastIndependentRecord",
                      timeZone = "America/Grenada",
                      stationCol = "Station",
                      writecsv = TRUE,
                      outDir = "D:/Ocelots_2020/Ocelot_Working_Folder",
                      metadataHierarchyDelimitor = "|",
                      metadataIDTag = "Individuals")

Det_Hist_Ocelot <- spatialDetectionHistory(recordTableIndividual = idRT,
                        species = "Ocelot_Camera_Trap_2020_renamed",
                        camOp = camop_prob,
                        CTtable = camdb,
                        output = "binary",
                        stationCol = "Station",
                        speciesCol = "Species",
                        Xcol = "xcoord",
                        Ycol = "ycoord",
                        individualCol = "Individual",
                        recordDateTimeCol = "DateTimeOriginal",
                        recordDateTimeFormat = "%d/%m/%Y %H:%M",
                        occasionLength = 7,
                        day1 = "station",
                        includeEffort = TRUE,
                        scaleEffort = FALSE,
                        binaryEffort = TRUE,
                        timeZone = "America/Grenada")



Juergen Niedballa

unread,
Jul 29, 2020, 9:18:58 AM7/29/20
to camtrapR
Hi Tyler, 
it is not so easy to figure it out without seeing the actual data, but normally the IDs should match between the camera trap table and camera operation matrix.
In cameraOperation, do you need to have the individual cameras at a station separate (argument byCamera = TRUE)? If not, you can pool all cameras at a station with  byCamera = FALSE. That might fix it already. 
If you need the camera operation matrix by camera (instead of by station only), would you please share a little sample data set (privately if you wish). 
Thank you,
Jürgen

tyler murray

unread,
Aug 1, 2020, 11:09:04 AM8/1/20
to camtrapR
Hi Jürgen,

Thank you for answering! 
I have considered pooling cameras pairs by station however I assume this would then not account for individual problems with cameras at the station. 
In my case, there are several stations where one camera stopped operating but the other remained on - therefore I chose to create the matrix by camera to obtain a more accurate description of operation at the sites.
Do let me know if you think this is unnecessary!
I'd be happy to share a small sample of data set and ct table to show how it is formatted. Please let me know and I will send it privately.

Thanks!
Tyler

Juergen Niedballa

unread,
Aug 1, 2020, 1:48:53 PM8/1/20
to camtrapR
Hi Tyler, 
there's ways to deal with such situations where one camera failed and the other worked, and you have a few options.
In brief, you can chose to 1) calculate daily effort by station summing up effort from different camera (which is probably what you want) or 2) consider the whole station not operational if one camera failed (effectively removing the data from the active station as well, so usually not desired). 

In cameraOperation, the argument allCamsOn controls this. Set it to FALSE for option 1 above, or TRUE for option 2. In a scenario with 2 cameras, 1 of them active, option 1 gives you a value "1" and option 2 gives "0" in the camera operation matrix.

Also, argument camerasIndependent helps here. It is FALSE if the cameras were operating as one unit, and their effort is not independent. That's the case when the second cameras does not increase detection probabilities compared to using only one camera, e.g. when using cameras in pairs facing each other and observing only one patch. If cameras at a station accumulate effort independently (e.g. by observing two different trails), set camerasIndependent = TRUE. 
So let's say you have 2 active cameras per day at a station now. If camerasIndependent = TRUE, the value in the camera operation matrix = 2 (they are independent). 
If camerasIndependent = FALSE, the value in the camera operation matrix = 1 (they are not indepenent).

In any case, you'd start with a camera trap table that includes a camera column and the Problem columns  indicating periods of malfunctioning by camera (see here and ?cameraOperation

I guess I should add a sample data set with camera IDs instead of station IDs only to illustrate those points better. You can also just play around with the arguments and see what happens. Also, note the little camopPlot() function in the vignette (here) that plots the camera operation matrix.

Please note also that I'm currently working on some changes to the cameraOperation function that will make it more precise by including the time of day instead of dates only (for setup, retrieval and malfunction). It should hopefully roll out in the next weeks. Only began working on it, but I'll think about how to possibly simplify things some more. I'll announce the updates here when they are ready.

Cheers,
Jürgen

tyler murray

unread,
Aug 4, 2020, 7:05:23 PM8/4/20
to camtrapR
Thanks Jürgen!

I will play around with the arguments as you suggested. 
Regarding the camera trap table are you suggesting that I have the column of camera ID replace that of station ID or have both (which is what I have now)?

Cheers,
Tyler

Juergen Niedballa

unread,
Aug 6, 2020, 6:02:35 AM8/6/20
to camtrapR
Hi Tyler,
since you have multiple cameras at a station, my suggestion is to have a camera column in addition to the station column, so both columns as you have now. That way you can easily specify periods in which one camera at a station did not work, and still count the station as active in cameraOperation() because the other cameras was operational. 
Best regards,
Jürgen

Reply all
Reply to author
Forward
0 new messages