Code Monkey home page Code Monkey logo

camtrapr's People

Contributors

git-og avatar jniedballa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

camtrapr's Issues

recordTable: n_images wrong when duplicate records exist and removeDuplicateRecords = FALSE

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)  

Please remove dependencies on **rgdal**, **rgeos**, and/or **maptools**

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.

Add number of individuals as possible output value of `detectionHistory` function

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.

camtrapR modernisation

Just a few ideas for potential future improvements:

Functions:

  • community occupancy models
  • detectionMaps: use sf instead of sp for shapefile export
  • multi-hierarchy metadata tag support (at least for species)
  • date and date/time arguments use lubridate syntax by default, maybe also internally (changed default arguments)
  • function for filtering for temporal independence in existing record tables
  • exiftoolPath -> addtopath()
  • detectionMaps: plot with ggplot. Optional basemaps (e.g. leaflet)?
  • activity... -> ggplot. Maybe one umbrella function with e.g. type = "radial", "density", "histogram" (also removes plotrix dependeny )
  • parallel processing, e.g. recordTable / imageRename
  • lifecycle to soft-deprecate old functions
  • allow multi-season models with camera IDs?
  • timeShiftImages at any stage of workflow
  • detectionHistory(): support occasions shorter than 1 day

Documentation

  • roxygenize, add @importFrom ...
  • vignette section on importing existing data
  • update & extend vignettes

Other

  • replace raster / sp with terra / sf
  • replace snow with parallel
  • Shiny surface, at least for some important functions?
  • read / write / convert camtrapdp data (maybe even change data structure used in camtrapR if camtrapdp gains traction)
  • fast metadata writing possible? (e.g. write station tag in HierarchicalMetadata, sth like writeDateTimeOriginal)

detection history values are 0 when effort = 0

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

Feature request: adding number of individuals as new column of record table

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:
image

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 πŸ‘‹

tidyverse and camtrapR - conflict ??

@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

surveyReport issue- camOp over multiple weeks

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<-

  • surveyReport(
  • recordTable = recordTable_A23,
  • CTtable = CTtable_A23,
  • camOp = camoperation,
  • speciesCol = "Species",
  • stationCol = "Station",
  • setupCol= "Setup_date",
  • retrievalCol= "Retrieval_date",
  • CTDateFormat = "ymd",
  • recordDateTimeCol = "DateTimeOriginal",
  • recordDateTimeFormat = "ymd HMS",
  • sinkpath = "C:/Users/laure/OneDrive/Documents/PhD/Analysis/Camera/Survey reports",
  • makezip = TRUE)
    CTtable was converted from tibble to data.frame
    recordTable was converted from tibble to data.frame
    saved output to file
    C:/Users/laure/OneDrive/Documents/PhD/Analysis/Camera/Survey reports/survey_report_2023-10-25.txt

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

problem columns in camera table

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.

skip ".dtrash" folder

digikam trash folder, has on occasion caused:
station directory "..." was not found in digiKam albums. Skipping

Maybe make an ignorelist for folder names

imageRename, probably others: error with empty inDir

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

About video tagging in digiKam

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.

createSpeciesFolders function does not work correctly with Khmer script

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.

recordTable: n_images column

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.

cameraOperation does not work with one camera

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!

Adding .mp4 compatibility to imageRename function

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.

image

surveyReport: zip files won't be produced on some systems.

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:

  1. Suggest R package "zip", with requireNamespace, with warning if nothing is available (preferred)
  2.    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

Openness in collaborations for improving visualization tools

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.

detectionMaps - allow multiple backgroundPolygons

see post in google group

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).

  • how to allow different style for each layer, e.g water blue, border grey etc.
  • implement as in raster::plot, addfun? Instead of providing data provide a plotting function? Then all the formatting arguments are taken care of already.
  • could be new argument or also be passed via backgroundPolygon (would be imprecise though, as it should also cover points and lines, and possible even raster images or Google Map tiles)

detectionHistory: occasion = 0 possible when recordDateTime is date only

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:

  1. Force users to provide time for dates (at least check + warn)
  2. if no time provided, assign 12 noon or something to allow difftime calculations (not midnight, then difference may be 0 again).

Read camtrap-dp data with camtrapR

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.