jniedballa / camtrapr Goto Github PK
View Code? Open in Web Editor NEWR package for camera trap data management
Home Page: https://jniedballa.github.io/camtrapR/
R package for camera trap data management
Home Page: https://jniedballa.github.io/camtrapR/
n_images can be >1 for duplicate records when
minDeltaTime = 0
removeDuplicateRecords = FALSE
(because exactly same time)
wd_images_ID <- system.file("pictures/sample_images", package = "camtrapR")
rec_table0 <- recordTable(inDir = wd_images_ID,
IDfrom = "directory",
minDeltaTime = 0,
removeDuplicateRecords = FALSE)
# these should be equal
nrow(rec_table0)
sum(rec_table0$n_images)
This package depends on (depends, imports or suggests) raster and one or more of the retiring packages rgdal, rgeos or maptools (https://r-spatial.org/r/2022/04/12/evolution.html, https://r-spatial.org/r/2022/12/14/evolution2.html). Since raster 3.6.3
, all use of external FOSS library functionality has been transferred to terra, making the retiring packages very likely redundant. It would help greatly if you could remove dependencies on the retiring packages as soon as possible.
Hi π
The function detectionHistory()
allows us to choose output
between the values "binary"
and "count"
, where "count"
is the counts of detections as described in the function documentation.
In the context of modelling research, @MartijnUH and @jimcasaer (Fauna management and Invasive Species team at INBO, Belgium) would like to add the number of individuals ("nind"
) as possible value of output
argument. See minimal example below:
Record table for a given date with the number of individuals added as extra column, see #25.
station | obsID | nIndividuals |
---|---|---|
A | 1 | 1 |
A | 2 | 3 |
B | 3 | 5 |
Detection history with output
= "count"
station | output |
---|---|
A | 2 |
B | 1 |
Detection history with the proposed new output
= "nind"
station | output |
---|---|
A | 4 |
B | 5 |
What do you think about it? I can work on this and send a PR if you wish.
Just a few ideas for potential future improvements:
Functions:
Documentation
Other
Should be NA. Happens when occasionLength = 1.
example(cameraOperation)
data(recordTableSample)
DetHist2 <- detectionHistory(recordTable = recordTableSample,
camOp = camop_problem,
stationCol = "Station",
speciesCol = "Species",
recordDateTimeCol = "DateTimeOriginal",
species = "VTA",
occasionLength = 1,
day1 = "station",
datesAsOccasionNames = FALSE,
includeEffort = TRUE,
scaleEffort = FALSE,
timeZone = "Asia/Kuala_Lumpur"
)
see StationC, occasion 39 onwards
As far as I understand, the record table doesn't contain information about the number of individuals. Do you think it's possible to add such information as an extra column? This will allow the users to use such information in their modelling and analyses.
Colleagues @jimcasaer and @MartijnUH at INBO (Wild life management and Invasive Species Team) asked me to add a similar column to the record tables I generate in camtraptor, see vignette and this screenshot:
Still, I would like to keep in touch with you as the main goal of camtraptor's get_record_table()
function is to generate a record table as similar as possible to the one camtrapR generates so that it can be used as input in camtrapR's detectionHistory()
.
In case you agree, I am also very open to discuss with you about the name and the position of this column. I could also work on this in a PR if you wish. Thanks π
Allow processing when problem columns are empty
camOp is not saved in zip. See 1859ed2
change makeSurveyZip to include.
@jniedballa can it be that there is a conflict between tidyverse and camtrapR
a got a error on the format in the detection history funtion that R does not recongnise the dataformat although it is exactly the way it should be
https://groups.google.com/g/camtrapr/c/LGpDdpQJRtw/m/h2qqFuJuAQAJ
See workspace in private email Oct 11 2023
Hello!
I am trying to generate a survey report, but it is not producing the output tables and plots. There is a problem with the camop table, and I believe it is because I undertook my full surveying over 6 weeks, with cameras out 9 of the total 27 stations for 2 weeks (because I had limited equipment). Therefore, all stations have NAs in the table for the times over the total sample period when they did not have cameras deployed. Is there any fix around this?
The code and error message are below:
surveyreport_A23<-
Error in (function (output, recordTable, CTtable, speciesCol, stationCol, :
unused argument (camOp = c(0.5, NA, 0.5, NA, NA, NA, NA, 0.5, NA, NA, NA, NA, NA, 0.5, 0.5, 0, NA, NA, NA, NA, 0.5, 0.5, 0.5, NA, NA, NA, NA, 1, NA, 1, NA, NA, NA, NA, 1, NA, NA, NA, NA, NA, 1, 1, 0, NA, NA, NA, NA, 1, 1, 1, NA, NA, NA, NA, 1, NA, 1, NA, NA, NA, NA, 1, NA, NA, NA, NA, NA, 1, 1, 0, NA, NA, NA, NA, 1, 1, 1, NA, NA, NA, NA, 1, NA, 1, NA, NA, NA, NA, 1, NA, NA, NA, NA, NA, 1, 1, 0, NA, NA, NA, NA, 1, 1, 1, NA, NA, NA, NA, 1, NA, 1, NA, NA, NA, NA, 1, NA, NA, NA, NA, NA, 1, 1, 0, NA, NA, NA,
NA, 1, 1, 1, NA, NA, NA, NA, 1, NA, 1, NA, NA, NA, NA, 1, NA, NA, NA, NA, NA, 1, 1, 0, NA, NA, NA, NA, 1, 1, 1, NA, NA, NA, NA, 1, NA, 1, NA, NA, NA, NA, 1, NA, NA, NA, NA, NA, 1, 1, 0, NA, NA, NA, NA, 1, 1, 1, NA, NA, NA, NA, 1, NA, 1, NA, NA, NA, NA, 1, NA, NA, NA, NA, NA, 1, 1, 0, NA, NA, NA, NA, 1, 1, 1, NA, NA, NA, NA, 1, NA, 1, NA, NA, NA, NA, 1, NA, NA, NA, NA, NA, 1, 1, 0, NA, NA, NA, NA, 1, 1, 1, NA, NA, NA, NA, 1, NA, 1, NA, NA, NA, NA, 1, NA, NA, NA, NA, NA, 1, 1, 0
in parseDateObject, this line fails when inputCol is POSIXct
inputColumn.char <- as.character(inputColumn)
Error in as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format
But when calling as.character outside parseDateObject() it works.
Fixed temporarily by calling as.character before calling parseDateObject, but it's still weird.
digikam trash folder, has on occasion caused:
station directory "..." was not found in digiKam albums. Skipping
Maybe make an ignorelist for folder names
Empty inDir (without subfolders) causes this error:
Error in rep("=", times = round(perc * progress_bar_width)) :
invalid 'times' argument
In addition: Warning message:
In system(command.tmp, intern = TRUE) :
running command 'exiftool -q -f -t -r -Directory -FileName -EXIF:DateTimeOriginal -ext JPG "NA"' had status 1
An issue about the video tagging workflow, in https://jniedballa.github.io/camtrapR/articles/camtrapr2.html you mentioned
BUT, in contrast to images, digiKam cannot write these tags directly into the video metadata.
Digikam used to have this issue (due to the limit of Exiv2), but since version 8.0 they provide ExifTool as an option for the metadata backend, which enables writing tags into video files (pretty much the same with images). Here is an example of the metadata:
ξ°Β exiftool ./Downloads/demo.mp4
ExifTool Version Number : 12.70
File Name : demo.mp4
...
XMP Toolkit : Image::ExifTool 12.70
Audio Bits Per Sample : 16
Minor Version : 0.2.0
Last Keyword XMP : Species/Glover's pika
Categories : <Categories><Category Assigned="0">Species<Category Assigned="1">Glover's pika</Category></Category></Categories>
Subject : Glover's pika
Color Label : 0
Pick Label : 0
Tags List : Species/Glover's pika
Date/Time Original : 2023:08:28 11:54:52
Exif Image Width : 2560
Exif Image Height : 1920
Hierarchical Subject : Species|Glover's pika
Catalog Sets : Species|Glover's pika
...
I'm contemplating whether it's necessary to simplify the existing video workflow, as digiKam db files are no longer needed. Please let me know if there's anything I missed.
When using species names with Khmer script, the folder are not created by the createSpeciesFolders
function.
With the following species names (or classification groups) used in createSpeciesFolders
, only folders for 0_Empty, 1_Deployment and collection, and Bird_unidentified will be created. The folders for the two that contain Khmer characters are not created.
0_Empty
1_Deployment and collection
Banteng_αααααα
Bird_unidentified
Chevrotain_ααααΆαααααααΌα
I assume this generalises to other non-Latin characters and to other functions, but I haven't tested it. For a quick workaround, I concatenated the classification groups with a file path, then used lapply(df$path, FUN = dir.create)
to create the folders from a list of file paths.
Check effect of removeDuplicateRecords on n_images column, document what the column shows (in vignette).
Reprroducible example:
examples(recordTable)
See difference between rec_table3a and rec_table3b.
Edit: n_images is wrong when
removeDuplicateRecords = F and minDeltaTime = 0.
special characters in directory names (+, etc) cause error messages. E.g. argument inDir in various functions
Hello,
I am using the cameraOperation
function with a CTable
argument having one row in some instances. The function works perfectly fine with 2 or more cameras, but throws an error when there is only one camera.
library(camtrapR)
df2 <- data.frame(setup = as.POSIXct(c("2020-04-01 12:00:00", "2020-05-01 12:00:00")),
retrieval = as.POSIXct(c("2020-04-10 12:00:00", "2020-05-10 12:00:00")),
camera = c("A01", "A02"))
# This works
camtrapR::cameraOperation(df2,
stationCol = "camera",
setupCol = "setup",
retrievalCol = "retrieval",
dateFormat = "Ymd HMS",
hasProblems = FALSE)
df1 <- data.frame(setup = as.POSIXct("2020-04-01 12:00:00"),
retrieval = as.POSIXct("2020-04-10 12:00:00"),
camera = "A01")
# This throws an error
camtrapR::cameraOperation(df1,
stationCol = "camera",
setupCol = "setup",
retrievalCol = "retrieval",
dateFormat = "Ymd HMS",
hasProblems = FALSE)
The error I get is the following:
Error in `rownames<-`(`*tmp*`, value = "A01Cam1"):
attempt to set 'rownames' on an object with no dimensions
I believe this error appeared in the newest version of camtrapR (2.3.0) and is caused by the renaming operation rownames(camop_binary) <- rownames(camOp_empty)
(in the function code), which is intended to be performed on rows of a matrix but happens on a vector when there is only one camera. I guess it should be easily fixable by setting a special case when there is only one camera!
Thank you for your time!
Are there any plans to add video (i.e. .mp4) compatability to the imageRename function?
Reconyx Ultrafires have readable dates where the file was created, that are extractable with exiftool. It looks to be stored in the "File" tag group in the 'FileModifyDate' metadata (time zone relative to the computer). Under the QuickTime meta data tag_group 'CreateDate' it has a time zone relative to the camera.
Perhaps forcing the user to specify what metadata to read dates + times from will help avoid and incorrect dating schemes that occur when files are moved and the file access date changes.
if Sys.getenv("R_ZIPCMD") and Sys.getenv("zip") are both empty, R cannot create zip files. It will do so without warning at the moment.
Solutions:
installr::install.rtools()
# To ensure you will get the zip file out, we can manually specify the path to...
# The zip tool in your C drive like mine below:
Sys.setenv(R_ZIPCMD= "C:/Rtools/bin/zip")
# Check it again
Sys.getenv("R_ZIPCMD")
Sys.getenv("zip")
-> might be too much hassle for average user
Hi @jniedballa. Before going too much in details, I would like to ask in this issue whether you are fine to accept PRs and actively give feedback for improving the visualization tools of camtrapR, which are quite basic at the moment.
At INBO they use already your package and therefore I find that improving this package is better than making a new one. In acse you are enthousiast about it, let me know and I will come in the future with some more specific issues.
Idea:
in detectionMaps, instead of allowing only 1 background polygon, give users freedom to add whatever spatial data they want underneath the points, each layer with its own graphics parameters. Vector data, possible even for raster data or Google Map tiles).
Include all species by default. But add function parameter for subsetting species.
e.g.
detectionHistory(..., recordDateTimeCol ="Date", recordDateTimeFormat = "dmy", day1 = "station" or "2015-12-01")
Seems to occur with output = "count" only.
When there is a record on the day the camera was set up and record times are dates without time, difftime between setup date and record date is 0. (detHist: # calculate the occasion each record belongs into from the time difference between records and beginning of the first occasion)
Then detHist: # fill detection matrix with 1 (or count) in appropriate cells can't access column 0,
causing this error:
"Error in record.hist[match(names(occasions.by.station)[xyz], rownames(record.hist)), :
number of items to replace is not a multiple of replacement length"
Possible solutions:
Camera Trap Data Package (Camtrap DP) has been greatly developed in the last months. And it will become a TDWG standard (see https://gitlab.com/oscf/camtrap-dp/-/issues/85) soon as it is mature enough. This means the use of this data format will greatly increase in the near future. Agouti uses already this format to export its data.
What do you think about a read function in camtrapR
for camtrap-dp formatted data? Is it already part of your dev branch? If not, I and other INBO colleagues (@jimcasaer and its colleagues of the Fauna and Invasive Species team) we are quit interested to work on this. Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.