## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = FALSE # legacy walkthrough shown as code only: set_*()/set_taxon()/ # out_camtrapdp() need internet (schema/taxonomy downloads), which # must not run during R CMD check. See the SchemaDriven vignette # for an executed, offline-buildable workflow. ) ## ----setup-------------------------------------------------------------------- # library(R2camtrapdp) ## ----------------------------------------------------------------------------- # #for the single deployment with video data # data("Vdep") # data("Vobs") # ## ----------------------------------------------------------------------------- # ##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) ## ----------------------------------------------------------------------------- # ##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) ## ----------------------------------------------------------------------------- # #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 # ) # ## ----------------------------------------------------------------------------- # datapackage<-R6_CamtrapDP$new() ## ----------------------------------------------------------------------------- # #set deployments # datapackage$set_deployments(deployments) # #set media # datapackage$set_media(media) # #set observations # datapackage$set_observations(observations) # ## ----------------------------------------------------------------------------- # #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) # ## ----------------------------------------------------------------------------- # datapackage$set_project(title=c("TestdatainNIES"), # samplingDesign = c("simpleRandom"), # captureMethod = c("activityDetection"), # individualAnimals = F, # observationLevel = c("media")) ## ----------------------------------------------------------------------------- # datapackage$set_st() ## ----------------------------------------------------------------------------- # datapackage$set_taxon() ## ----------------------------------------------------------------------------- # #set timezone ("Asia/Tokyo" is default value) # tz="Asia/Tokyo" # #update datetime # datapackage$update_created() ## ----------------------------------------------------------------------------- # 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")) ## ----------------------------------------------------------------------------- # datapackage$add_relatedIdentifiers(relationType = c("IsSupplementTo"), # relatedIdentifier =as.character(c("https://doi.org/10.34462/0002000233")) , # relatedIdentifierType = c("DOI"), # resourceTypeGeneral = c("JournalArticle")) ## ----------------------------------------------------------------------------- # datapackage$set_properties(name=c("testdata-nies"), # homepage = c("https://www.nies.go.jp/biology/snapshot_japan/index.html")) ## ----------------------------------------------------------------------------- # datapackage$add_sources(title=c("TestdatainNIES")) ## ----------------------------------------------------------------------------- # datapackage$add_references(reference=c("TestdatainNIES https://doi.org/10.34462/0002000233")) ## ----------------------------------------------------------------------------- # #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) ## ----------------------------------------------------------------------------- # data_camtrapdp<-datapackage$out_camtrapdp() ## ----eval=FALSE--------------------------------------------------------------- # datapackage$out_camtrapdp(write=T,directory=path)