If you have deployment and observation data.
[Single Camera] Using deployment data (e.g., Vdep), deployment (tibble data) was created as below,
##create deployment
deployments<-create_deployments(
deploymentID=Vdep$deploymentID,
longitude=Vdep$longitude,
latitude=Vdep$latitude,
locationID=Vdep$locationID,
deploymentStart_date=Vdep$startDate,
deploymentStart_time=Vdep$startTime,
deploymentEnd_date=Vdep$endDate,
deploymentEnd_time=Vdep$endTime,
cameraID=Vdep$cameraID,
cameraModel=Vdep$cameraModel,
cameraDelay=Vdep$Delay,
cameraHeight=Vdep$Height,
baitUse=Vdep$bait,
setupBy=Vdep$setupBy)[Single Camera] Using deployment and observation data (e.g., Vdep and Vobs), media (tibble data) was created as below,
##settings
#media ID
mediaIDv<-paste(Vobs$institutionCode,
Vobs$collectionCode,
Vobs$locationID,
as.numeric(factor(Vobs$filename)),
sep="_")
#capture method
capturemethod<-"activityDetection"
nmedia<-length(mediaIDv)
captureMethod<-rep(capturemethod,nmedia)
#filePath
filePath<-paste("Video")
#fileName
fileName<-Vobs$filename
filetype<-tolower(unlist(lapply(strsplit(fileName,"\\."),"[",2)))
#filePublic
fileMediatype<-paste("video",filetype,sep="/")
filePublic<-!grepl("ヒト",fileName)
##create media
media<-create_media( mediaID=mediaIDv,
deploymentID=Vdep$deploymentID,
timestamp_date=Vobs$date,
timestamp_time=Vobs$time,
filePath=filePath,
filePublic=filePublic,
fileMediatype=fileMediatype,
captureMethod="activityDetection",
fileName=fileName)[Single Camera] Using observation data (e.g., Vobs), observation (tibble data) was created as below,
#If the observations were media-based observations, observationLevel expressed as "media"
observationLevel<-"media"
#If the observations classified by human, classificationmethod expressed as "human"
classificationmethod<-"human"
#classificationprobability is the degree of certainty of the classification of the observed object (1=maximum certainty)
classificationprobability<-1
#create observationIDs that express the unique identifier of the observation
observationID<-paste(mediaIDv,Vobs$VideoID,sep="_")
#deploymentID is belong to deployment
deploymentID<-Vdep$deploymentID
#mediaID is belong to media
mediaID<-mediaIDv
#Timestamp (date and time) at which the observation started (e.g., the timestamp when the video or photo was taken)
tz="Asia/Tokyo"
timestamp<-paste(Vobs$date,Vobs$time)
#categorized observationType (animal, human, vehicle, blank, unknown, or unclassified)
observationType<-ifelse(Vobs$object=="hito","human",
ifelse(Vobs$object=="none","blank",
ifelse(Vobs$object=="unidentifiable","unknown","animal")))
#Scientific name of the animals observed
scientificName<-ifelse(is.na(Vobs$genus),Vobs$class,paste(Vobs$genus,Vobs$species))
#create observations
observations<-create_observations(observationID=observationID,
deploymentID=deploymentID,
mediaID=mediaID,
eventStart=timestamp,
eventEnd=timestamp,
observationLevel=observationLevel,
observationType=observationType,
scientificName=scientificName,
count=Vobs$individualCount,
classificationMethod=classificationmethod,
classificationProbability=classificationprobability
)1.Create an R6 object with named “datapackage”
2.Import tibble data (deployment, media and observation) into
“datapackage”
The functions “set_deployments()”, “set_media()”, and
“set_observations()” can be used as below;
#set deployments
datapackage$set_deployments(deployments)
#set media
datapackage$set_media(media)
#set observations
datapackage$set_observations(observations)3.Import metadata (e.g., contributors, licences, and
properties) into “datapackage”
For the metadata of Camera Trap Data Package (Camtrap DP), five
properties (contributors, project, spatial, temporal and taxonomic, and
created) are required. In addition, six properties can be used for
additional information of metadata.
3-1.Required Properties
3-1-1.Contributors
The function “add_contributors()” can be used to import a data frame of
contributors. The contributor data frame consists of title, email, path,
role, and organization.
title: Name of contributor.
email: e-mail address of contributor.
path: URL for the contributor’s web page.
role: Role of contributor. Defaults to contributor.
Other role can use from contact, principalInvestigator, rightsHolder and
publisher.
organization: Organization of contributor.
Import contributors into “datapackage” as below,
#create dataframe of contributors
cd<-data.frame(title=c("Keita Fukasawa", "Kana Terayama"),
email=c("fukasawa@nies.go.jp","terayama.kana@nies.go.jp"),
path=c("https://orcid.org/0000-0003-0272-9180","https://orcid.org/0000-0001-6935-7233"),
role=as.factor(c("contact","principalInvestigator")),
organization=c("National Institute for Environmental Studies (NIES)","National Institute for Environmental Studies (NIES)"))
datapackage$add_contributors(cd)3-1-2.Project
The information of Camera trap project or study that originated the
package. For project, title, samplingDesign, captureMethod,
individualAnimals, and observationLevel are need to be filled in. In
addition, id, acronym, description, path are available as additional
information.
[Required information]
title: Title of the project.
samplingDesign: Type of sampling design/layout. The
values can be used from simpleRandom, systematicRandom, clusteredRandom,
experimental, targeted, or opportunistic.
captureMethod: Method used to capture the media files,
values activityDetection or timeLapse can be used.
individualAnimals: true if the project includes marked
or recognizable individuals.
observationLevel: Level at which observations are
provided, values media or event can be used.
[Additional information]
id: Unique identifier of the project.
acronym: Project acronym.
description: Description of the project.
path: Path for project website.
The function “set_project()” can be used to import for project into “datapackage”. [For media based observation]
datapackage$set_project(title=c("TestdatainNIES"),
samplingDesign = c("simpleRandom"),
captureMethod = c("activityDetection"),
individualAnimals = F,
observationLevel = c("media"))3-1-3.Spatial and temporal
Spatial and temporal coverage of the “package”.
The function “set_st()” collects spatial and temporal data from
“deployment” and can be imported into “datapackage”.
3-1-4.Taxonomic
Taxonomic coverage of the “datapackage”, based on the unique
“scientificName” of “observation”.
The “set_taxon()” function lists scientific name of observation and
collect taxonID, taxonRank, kingdom, phylum, class, order, family, and
genus from taxon data base (express as taxonDB). For default, taxonDB is
“gbif”. You can use other taxonDB (see details in
“taxadb::get_ids”).
3-1-5.Created
The datetime on which “datapackage” was created.
The “update_created()” function gets the current datetime from system
time and can be update the datetime on which “datapackage” was
created.
#set timezone ("Asia/Tokyo" is default value)
tz="Asia/Tokyo"
#update datetime
datapackage$update_created()3-2.Additional properties
3-2-1.Licenses
The information of licenses related to “datapackage” can be listed as
metadata. If provide, “Camtrap DP” further requires at least a license
for content of the “package” and one for the media files. The function
“add_license()” can be used as below,
datapackage$add_license(name=c("CC-BY-4.0"),
path=c("http://creativecommons.org/licenses/by/4.0/"),
scope=c("data"))
datapackage$add_license(name=c("CC-BY-4.0"),
path=c("http://creativecommons.org/licenses/by/4.0/"),
scope=c("media"))Note that this function need to use for each license information.
3-2-2.Related Identifiers
Identifiers of resources related to the “package” (e.g., papers, project
pages, derived datasets, APIs etc.). The function
“add_relatedIdentifiers()” can be used to import related identifiers.
The related identifiers need to set relationType, relatedIdentifier,
resourceTypeGeneral, and relatedIdentifierType.
relationType: Description of the relationship
between the resource (the “package”) and the related resource. Available
from IsCitedBy, Cites, IsSupplementTo, IsSupplementedBy, IsContinuedBy,
Continues, IsNewVersionOf, IsPreviousVersionOf, IsPartOf, HasPart,
IsPublishedIn, IsReferencedBy, References, IsDocumentedBy, Documents,
IsCompiledBy, Compiles, IsVariantFormOf, IsOriginalFormOf,
IsIdenticalTo, HasMetadata, IsMetadataFor, Reviews, IsReviewedBy,
IsDerivedFrom, IsSourceOf, Describes, IsDescribedBy, HasVersion,
IsVersionOf, Requires, IsRequiredBy, Obsoletes, or IsObsoletedBy.
relatedIdentifier: Unique identifier of the related
resource (e.g., a DOI or URL).
resourceTypeGeneral: General type of the related
resource. Available from Audiovisual, Book, BookChapter, Collection,
ComputationalNotebook, ConferencePaper, ConferenceProceeding, DataPaper,
Dataset, Dissertation, Event, Image, InteractiveResource, Journal,
JournalArticle, Model, OutputManagementPlan, PeerReview, PhysicalObject,
Preprint, Report, Service, Software, Sound, Standard, Text, Workflow,
and Other.
relatedIdentifierType: Type of the RelatedIdentifier.
Available from ARK, arXiv, bibcode, DOI, EAN13, EISSN, Handle, IGSN,
ISBN, ISSN, ISTC, LISSN, LSID, PMID, PURL, UPC, URL, URN, and w3id.
datapackage$add_relatedIdentifiers(relationType = c("IsSupplementTo"),
relatedIdentifier =as.character(c("https://doi.org/10.34462/0002000233")) ,
relatedIdentifierType = c("DOI"),
resourceTypeGeneral = c("JournalArticle"))3-2-3.Properties
The “set_properties()” function can be used to list some additional
information about the “datapackage” as metadata. The values can be used
as shown below;
directory: Working directory.
name: Identifier of the resource.
id: A property reserved for globally unique
identifiers. (e.g., UUID and DOI) description:
Description of “datapackage”.
version: The Camtrap DP version of “datapackage”. The
default is “1.0.1”.
profile: Profile of the resource. The default is
https://raw.githubusercontent.com/tdwg/camtrap-dp/<version>/camtrap-dp-profile.json.
keywords: Keywords of “datapackage”.
image: A URL or Path of an image for
“datapackage”.
homepage: A URL for the home on the web that is related
to “datapackage”.
bibliographicCitation: A bibliographical reference for
the resource.
coordinatePrecision: Least precise coordinate precision
of the latitude and longitude of “deployment”.
datapackage$set_properties(name=c("testdata-nies"),
homepage = c("https://www.nies.go.jp/biology/snapshot_japan/index.html"))3-2-4.Source
The “add_sources()” function can be used to list the sources of
“datapackage”. The values of title (title of the sources), path (path or
URL to the source), email (an email address), and version (the version
of “datapackage”) are available for this function.
3-2-5.Reference
List of references related to the “package”. References preferably
include a DOI.
3-2-6.Custom Information
If you have some of the “datapackage” information as metadata, but it is
not listed in the above sections, the “set_custom()” function will help.
This function can be used to list new data from a data frame, and the
values of name, description , and of course data frame are
required.
For example,suppose you have a data frame for estimating animal
abundance based on the REST method. The code is as follows,
#data frame of REST data (This is dummy data)
RD<-data.frame(id=seq(1:38),
Time=sample(1:29,38,replace=T))
##add REST data as medatada
datapackage$set_custom(name=c("rest"),
description = c("dataforRESTmethod"),
data=RD)4.Convert and output as Camtrap DP object
The R6class object (i.e., “datapackage”) can be converted to the Camtrap
DP object using the “out_camtrapdp()” function, as shown below,
If you want, “datapackage” can be converted to the Camtrap DP object and created in the directory (described by path), as shown below,