## ----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 multiple deployments with images data # data("Idep") # data("Iobs") ## ----------------------------------------------------------------------------- # ##create deployment # deployments<-create_deployments( # deploymentID=Idep$deploymentID, # longitude=Idep$longitude, # latitude=Idep$latitude, # locationID=Idep$locationID, # deploymentStart_date=Idep$startDate, # deploymentStart_time=Idep$startTime, # deploymentEnd_date=Idep$endDate, # deploymentEnd_time=Idep$endTime, # cameraID=Idep$cameraID, # cameraModel=Idep$cameraModel, # cameraDelay=Idep$Delay, # cameraHeight=Idep$Height, # baitUse=Idep$bait, # setupBy=Idep$setupBy) ## ----------------------------------------------------------------------------- # ##settings # #media ID # mediaIDi<-paste(Iobs$institutionCode, # Iobs$collectionCode, # Iobs$locationID, # as.numeric(factor(Vobs$filename)), # sep="_") # # #capture method # capturemethod<-"activityDetection" # nmedia<-length(mediaIDi) # captureMethod<-rep(capturemethod,nmedia) # # #filePath # filePath<-paste("Image") # # #fileName # fileName<-Iobs$filename # filetype<-tolower(unlist(lapply(strsplit(fileName,"\\."),"[",2))) # # #filePublic # fileMediatype<-paste("image",filetype,sep="/") # filePublic<-!grepl("ヒト",fileName) # # ##create media # media<-create_media( mediaID=mediaIDi, # deploymentID=Iobs$deploymentID, # timestamp_date=Iobs$date, # timestamp_time=Iobs$time, # filePath=filePath, # filePublic=filePublic, # fileMediatype=fileMediatype, # captureMethod="activityDetection", # fileName=fileName) ## ----------------------------------------------------------------------------- # #If the observations were event-based observations, observationLevel expressed as "event" # observationLevel<-"event" # # #If the observations classified by human, classificationmethod expressed as "humam" # 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(mediaIDi,Iobs$obsID,sep="_") # #deploymentID is belong to deployment # deploymentID<-Iobs$deploymentID # #eventID is belong to the event # eventID<-Iobs$eventID # # #Time zone for time stamp (date and time) at which the observation started and ended and ended ( start and end time need for event-based observation) # tz="Asia/Tokyo" # # #categorized observationType (animal, human, vehicle, blank, unknown, or unclassified) # observationType<-ifelse(Iobs$object=="hito","human", # ifelse(Iobs$object=="none","blank", # ifelse(Iobs$object=="unidentifiable","unknown","animal"))) # # #Scientific name of the animals observed # scientificName<-ifelse(is.na(Iobs$genus),Iobs$class,paste(Iobs$genus,Iobs$species)) # # #create observations # observations<-create_observations(observationID=observationID, # deploymentID=deploymentID, # eventID = eventID, # eventStart=Iobs$eventStart, # eventEnd=Iobs$eventEnd, # observationLevel=observationLevel, # observationType=observationType, # scientificName=scientificName, # count=Iobs$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("DummyData"), # samplingDesign = c("simpleRandom"), # captureMethod = c("activityDetection"), # individualAnimals = F, # observationLevel = c("event")) ## ----------------------------------------------------------------------------- # 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.xxxx")) , # relatedIdentifierType = c("DOI"), # resourceTypeGeneral = c("JournalArticle")) ## ----------------------------------------------------------------------------- # datapackage$set_properties(name=c("dummy-nies"), # homepage = c("https://www.nies.go.jp/biology/snapshot_japan/index.html")) ## ----------------------------------------------------------------------------- # datapackage$add_sources(title=c("DummyData")) ## ----------------------------------------------------------------------------- # datapackage$add_references(reference=c("DummuyNIES https://doi.org/xxxxx")) ## ----------------------------------------------------------------------------- # #data frame of REST data (This is dummy data) # RD<-data.frame(id=seq(1:388), # Time=sample(1:29,388,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)