Activity Density and Activity Overlap Error

97 views
Skip to first unread message

Nor Bazilah Razali

unread,
May 24, 2023, 11:27:06 AM5/24/23
to camtrapR
Hello everyone,

I was trying to plot activity density after generate record table when the first error occurred. The first error was as below:

> str(rec.table60)
'data.frame': 201 obs. of  14 variables:
 $ Station             : chr  "MD01" "MD01" "MD01" "MD01" ...
 $ Species             : chr  "Leopard" "Lesser Mousedeer" "Malayan Porcupine" "Malayan Porcupine" ...
 $ DateTimeOriginal    : POSIXct, format: "2022-08-07 17:03:37" "2022-08-17 14:43:42" ...
 $ Date                : Date, format: "2022-08-07" "2022-08-17" ...
 $ Time                : chr  "17:03:37" "14:43:42" "21:47:33" "20:58:07" ...
 $ delta.time.secs     : num  0 0 0 688233 351363 ...
 $ delta.time.mins     : num  0 0 0 11470 5856 ...
 $ delta.time.hours    : num  0 0 0 191.2 97.6 ...
 $ delta.time.days     : num  0 0 0 8 4.1 0.1 1 0.2 1.8 0 ...
 $ Directory           : chr  "C:/Users/Dell/Desktop/Main Dam/imageRENAMED/MD01/Leopard" "C:/Users/Dell/Desktop/Main Dam/imageRENAMED/MD01/Lesser Mousedeer" "C:/Users/Dell/Desktop/Main Dam/imageRENAMED/MD01/Malayan Porcupine" "C:/Users/Dell/Desktop/Main Dam/imageRENAMED/MD01/Malayan Porcupine" ...
 $ FileName            : chr  "MD01__1__2022-08-07__17-03-37(1).JPG" "MD01__1__2022-08-17__14-43-42(1).JPG" "MD01__1__2022-08-04__21-47-33(1).JPG" "MD01__1__2022-08-12__20-58-07(1).JPG" ...
 $ metadata_EnglishName: chr  "NA" "NA" "NA" "NA" ...
 $ n_images            : int  2 2 2 2 2 1 2 2 5 2 ...
 $ HierarchicalSubject : chr  "English Name|LEOPARD" "English Name|LESSER MOUSE DEER" "English Name|MALAYAN PORCUPINE" "English Name|MALAYAN PORCUPINE" ...
> activityDensity(recordTable          = rec.table60,
+                 species              = "Red Junglefowl",
+                 allSpecies           = FALSE,
+                 speciesCol           = "Species",
+                 recordDateTimeCol    = "DateTimeOriginal",
+                 recordDateTimeFormat = "%Y-%m-%d %H:%M:%S",
+                 plotR                = TRUE,
+                # writePNG            = FALSE,
+                # plotDirectory,
+                #createDir            = FALSE,
+                 #pngMaxPix           = 1000,
+                 add.rug              = TRUE
+ )
datetime column is in POSIXct format. Converting to character: recordTable[, recordDateTimeCol] FALSE
Error: 3 out of 201 records in c("2022-08-07 17:03:37", "2022-08-17 14:43:42", "2022-08-04 21:47:33",  cannot be interpreted using dateTimeFormat: %Y-%m-%d %H:%M:%S
 rows 169, 170, 1713 out of 201 records in "2022-08-12 20:58:07", "2022-08-16 22:34:11", "2022-08-17 01:59:27",  cannot be interpreted using dateTimeFormat: %Y-%m-%d %H:%M:%S
 rows 169, 170, 1713 out of 201 records in "2022-08-18 01:06:38", "2022-08-18 06:36:19", "2022-08-20 00:34:11",  cannot be interpreted using dateTimeFormat: %Y-%m-%d %H:%M:%S
 rows 169, 170, 1713 out of 201 records in "2022-08-22 05:06:56", "2022-08-16 17:01:45", "2022-08-17 16:40:36",  cannot be interpreted using dateTimeFormat: %Y-%m-%d %H:%M:%S
 rows 169, 170, 1713 out of 201 records in "2022-08-19 18:04:09", "2022-08-19 19:44:31", "2022-08-20 06:39:23",  cannot be interpreted using dateTimeFormat: %Y-%m-%d %H:%M:%S
 rows 169, 170, 1713 out of 201 records in "2022-08-02 12:17:00", "2022-08-22 10:31:01", "2022-08-02 23:18:07",  cannot be interpr

I have gone through this forum and read threads about almost similar errors to mine. I thought the error was related to the datetime format in POSIXct format and tried to convert to character before running activityDensity. However, I came across another error below:

> rec.table60$DateTimeOriginal <- as.character(rec.table60$DateTimeOriginal)
> str(rec.table60)
'data.frame': 201 obs. of  14 variables:
 $ Station             : chr  "MD01" "MD01" "MD01" "MD01" ...
 $ Species             : chr  "Leopard" "Lesser Mousedeer" "Malayan Porcupine" "Malayan Porcupine" ...
 $ DateTimeOriginal    : chr  "2022-08-07 17:03:37" "2022-08-17 14:43:42" "2022-08-04 21:47:33" "2022-08-12 20:58:07" ...
 $ Date                : Date, format: "2022-08-07" "2022-08-17" ...
 $ Time                : chr  "17:03:37" "14:43:42" "21:47:33" "20:58:07" ...
 $ delta.time.secs     : num  0 0 0 688233 351363 ...
 $ delta.time.mins     : num  0 0 0 11470 5856 ...
 $ delta.time.hours    : num  0 0 0 191.2 97.6 ...
 $ delta.time.days     : num  0 0 0 8 4.1 0.1 1 0.2 1.8 0 ...
 $ Directory           : chr  "C:/Users/Dell/Desktop/Main Dam/imageRENAMED/MD01/Leopard" "C:/Users/Dell/Desktop/Main Dam/imageRENAMED/MD01/Lesser Mousedeer" "C:/Users/Dell/Desktop/Main Dam/imageRENAMED/MD01/Malayan Porcupine" "C:/Users/Dell/Desktop/Main Dam/imageRENAMED/MD01/Malayan Porcupine" ...
 $ FileName            : chr  "MD01__1__2022-08-07__17-03-37(1).JPG" "MD01__1__2022-08-17__14-43-42(1).JPG" "MD01__1__2022-08-04__21-47-33(1).JPG" "MD01__1__2022-08-12__20-58-07(1).JPG" ...
 $ metadata_EnglishName: chr  "NA" "NA" "NA" "NA" ...
 $ n_images            : int  2 2 2 2 2 1 2 2 5 2 ...
 $ HierarchicalSubject : chr  "English Name|LEOPARD" "English Name|LESSER MOUSE DEER" "English Name|MALAYAN PORCUPINE" "English Name|MALAYAN PORCUPINE" ...
> activityDensity(recordTable          = rec.table60,
+                 species              = "Red Junglefowl",
+                 allSpecies           = FALSE,
+                 speciesCol           = "Species",
+                 recordDateTimeCol    = "DateTimeOriginal",
+                 recordDateTimeFormat = "%Y-%m-%d %H:%M:%S",
+                 plotR                = TRUE,
+                # writePNG            = FALSE,
+                # plotDirectory,
+                #createDir            = FALSE,
+                 #pngMaxPix           = 1000,
+                 add.rug              = TRUE
+ )
Error: 3 out of 201 records in recordTable[, recordDateTimeCol] cannot be interpreted using dateTimeFormat: %Y-%m-%d %H:%M:%S
 rows 169, 170, 171

I also tried changing the recordDateTimeFormat to "ymd HMS" but to no avail.

Thank you.

Regards,
Bazilah

Alexandre Courtiol

unread,
May 24, 2023, 11:32:23 AM5/24/23
to Nor Bazilah Razali, camtrapR
Hi Bazilah,
Does the output of rec.table60$DateTimeOriginal[c(169, 170, 171)] look weird or at least different from other date time elements?
Thanks

--
You received this message because you are subscribed to the Google Groups "camtrapR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camtrapr+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/camtrapr/36ff92eb-1ad7-4621-ae2b-76001f4bdd02n%40googlegroups.com.


--
Alexandre Courtiol, www.datazoogang.de

Nor Bazilah Razali

unread,
May 24, 2023, 11:50:18 AM5/24/23
to camtrapR
Hi Alexandre, 

Yeah, the output of rec.table60$DateTimeOriginal[c(169,170,1710)] were different from other date time elements. Instead of 2022 when the camera traps were deployed, somehow this particular camera trap revert back to the factory setting (2017). I also attached the rec.table60.xlsx for your perusal.

Thank you.

Regards,
Bazilah

rec.table60.xlsx

Alexandre Courtiol

unread,
May 24, 2023, 11:56:46 AM5/24/23
to Nor Bazilah Razali, camtrapR
Re Bazilah,
That the year is 2017 rather than 2022 may be an issue for your results, but it is not what makes camtrapR fail.
What makes it fail is that those are dates and not date time elements, so the vector you use for recordDateTimeCol is heterogeneous and cannot be parsed using recordDateTimeFormat = "%Y-%m-%d %H:%M:%S".
Perhaps there is a smarter way (Jurgen will tell), but I would either fix that in the raw data or drop those rows altogether if you don't know what the real date times were.





--
Alexandre Courtiol, www.datazoogang.de

Juergen Niedballa

unread,
May 26, 2023, 10:26:20 PM5/26/23
to camt...@googlegroups.com

Hi Bazilah & Alexandre,

as Alex suggested the elements of DateTimeOriginal in rows 169-171 are different from the rest. It can be seen in the xlsx that they are dates without a time component (2017-01-01).

You can theoretically paste the Date and Time columns to recreate valid entries for DateTimeOriginal (that's the main reason they exist), but in this case time also defaulted to 00:00:00. So pasting the date and time will not be informative.

I don't know what caused the problem that camera, but three different records all with the same default date/time suggests that camera probably keeps resetting date/time. If so the issue is more severe than just a time offset (which could be fixed with the timeShiftImages() function). If so and I don't see a fix for it with the information at hand.

I'd suggest to also check the metadata of one of those images for potentially helpful date/time information (use function exifTagNames() or check in digiKam) that could possibly be extracted.

Best regards,

Jürgen

Nor Bazilah Razali

unread,
May 31, 2023, 1:49:58 AM5/31/23
to camtrapR
Hi Alexandre and Jurgen,

I have already tried to exclude those rows (169-171) as suggested by Alexandre and the analysis works fine. For the time being, I'll stick to this method and will try the timeShiftImages/ exifTagNames function as suggested by Jurgen.

I have no idea why the camera keeps resetting the date/time. It might be the camera was the defective product in the first place. I'll be sure to take note of this for future camera trap image analysis. 

Thank you very much for your assistance.

Regards,
Bazilah

Jürgen Niedballa

unread,
May 31, 2023, 11:35:42 PM5/31/23
to Nor Bazilah Razali, camtrapR
Hi Bazilah,
Agreed, it sounds like the camera is defective and there's nothing much we can do about it.

The different data format should not happen nevertheless. It essentially interpreted the midnight time as a date, and I suspect Excel is the culprit. 
Can you please check if the format of rows 169 to 171 is consistent with the others (has a time component) directly in the output of recordTable?

If not, it would be a bug. If you're unsure feel free to share one of those faulty image for test purposes.

Thank you,
Jürgen 


Nor Bazilah Razali

unread,
Jun 26, 2023, 1:15:30 AM6/26/23
to camtrapR
Hi  Jürgen,

Sorry for the delayed response. I have been occupied with work for the past few weeks. 

I am unsure about the format of rows 169 to 171. So, attached is one of those faulty images for test purposes.

Thank you very much for your assistance.

Regards,
Bazilah
MD08__1__2017-01-01__00-00-00(4).JPG

Juergen Niedballa

unread,
Jun 28, 2023, 7:57:26 AM6/28/23
to camtrapR
Hi,
there is nothing wrong with the format of the metadata in the image. Checked with digiKam and it shows:
2017:01:01 00:00:00
So the format is correct, but the value is wrong.

Two possible explanations for the mismatch in formats:
1) When running recordTable on a folder with only this one image it returns only a date in DateTimeOriginal. So if all images from a camera trap station are affected you may not see the time information. That's a bug due to a very unusual situation
2) Excel may be the culprit again. It likes to auto-format columns and then removes the "uninformative" time 00:00:00.

Either way, there is no usable date/time information in the images, so it is unlikely you can use these images in a straightforward way for most of the usual analyses (apart from confirming presence of species at that location).

Best,
Jürgen

Nor Bazilah Razali

unread,
Sep 18, 2023, 4:54:24 AM9/18/23
to camtrapR
Hi  Jürgen,

Thank you for the explanations. It'll be helpful when I analyse camera trap images in the future. Let's say the faulty images are the only data I had. Is it possible for me to edit the rec.table60$DateTimeOriginal[c(169, 170, 171)] in R/excel to the date of the camera trap installed and run again recordTable script analysis to get the accurate result?

Thank you,
Bazilah

Zakariaa Bouabbad

unread,
Sep 20, 2023, 7:04:32 PM9/20/23
to Nor Bazilah Razali, camtrapR
good evening everyone, I hope you are well, I have a question are there examples of databases to start my work on the study of mammals knowing that I study several methods for my research



Reply all
Reply to author
Forward
0 new messages