library(dplyr)
library(here)
library(lubridate)
library(knitr)
library(stringr)
all<-read.csv("all_data_exif_out.csv")
Area Table
sites<-all %>%
select(Site.ID)%>%
distinct()
sites$SiteName<-NULL
sites$SiteName[sites$Site.ID == "MN"]<- "Mara North"
sites$SiteName[sites$Site.ID == "MT"]<- "Mara Triangle"
sites$SiteName[sites$Site.ID == "NB"]<- "Naboisho"
sites$SiteName[sites$Site.ID == "OMC"]<- "Olare Motorogi Consrevancy"
sites$Country<-"Kenya"
colnames(sites)<-c("Area", "AreaName", "Country")
kable(sites)
| MN |
Mara North |
Kenya |
| MT |
Mara Triangle |
Kenya |
| NB |
Naboisho |
Kenya |
| OMC |
Olare Motorogi Consrevancy |
Kenya |
#write.csv(sites, here::here("database/kenya_data/AreaTbl.csv"), row.names = FALSE)
Location Table
locs<-read.csv("CameraLocations.csv")
locs$coordSystem<-NULL
locs$coordSystem<-"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs "
locs$area<-NULL
locs$area[grepl("MN",locs$Location.ID)]<- "MN"
locs$area[grepl("MT",locs$Location.ID)]<- "MT"
locs$area[grepl("NB",locs$Location.ID)]<- "NB"
locs$area[grepl("OMC",locs$Location.ID)]<- "OMC"
colnames(locs)<-c("Location", "Latitude", "Longitude","CorrdSystem","Area" )
kable(summary(locs))
|
MN02 : 1 |
Min. :-1.463 |
Min. :34.90 |
Length:180 |
Length:180 |
|
MN04 : 1 |
1st Qu.:-1.399 |
1st Qu.:35.03 |
Class :character |
Class :character |
|
MN05 : 1 |
Median :-1.354 |
Median :35.17 |
Mode :character |
Mode :character |
|
MN06 : 1 |
Mean :-1.336 |
Mean :35.15 |
NA |
NA |
|
MN07 : 1 |
3rd Qu.:-1.270 |
3rd Qu.:35.26 |
NA |
NA |
|
MN08 : 1 |
Max. :-1.165 |
Max. :35.41 |
NA |
NA |
|
(Other):174 |
NA |
NA |
NA |
NA |
#write.csv(locs, here::here("database/kenya_data/LocationTbl.csv"), row.names = FALSE)
Field Season Table
cam<-read.csv("CameraDateData.csv")
cam$Start_1<-as.Date(cam$Start_1, format = "%d-%m-%y")
cam$End_1<-as.Date(cam$End_1, format = "%d-%m-%y")
cam$Start_2<-as.Date(cam$Start_2, format = "%d-%m-%y")
cam$End_2<-as.Date(cam$End_2, format = "%d-%m-%y")
#cam[(cam$End_1 - cam$Start_1) >cam$No_Days_1,]
season<-data.frame("Kenya_1", year(cam$Start_1[1]),min(na.omit(cam$Start_1)),max(na.omit(cam$End_2)), nrow(cam), "Kenya")
colnames(season)<-c("Season", "Year", "StartDate", "EndDate", "NumCameras", "Country")
kable(season)
| Kenya_1 |
2018 |
2018-10-05 |
2018-11-29 |
177 |
Kenya |
#write.csv(season, here::here("database/kenya_data/FieldSeasonTbl.csv"), row.names = FALSE)
Deployment Table
dep1<-cam[,1:5]
dep2<-cam[,c(1,6:9)]
names<-c("Location_ID", "Camera_ID", "Start", "End", "No_Days")
colnames(dep1)<-names
colnames(dep2)<-names
dep1$Deployment<-"Kenya_1.1" #1 for season .1 for deployment
dep2$Deployment<-"Kenya_1.2"
dep<-rbind(dep1,dep2)
dep$Country<-"Kenya"
dep$Season<-"Kenya_1"
dep<-dep[!is.na(dep$Start) & !is.na(dep$End),]
dep_out<-dep %>%
group_by(Deployment, Country, Season)%>%
summarise(StartDate = min(na.omit(Start)), EndDate = max(na.omit(End)), NumCameras = n())
kable(dep_out)
| Kenya_1.1 |
Kenya |
Kenya_1 |
2018-10-05 |
2018-11-27 |
172 |
| Kenya_1.2 |
Kenya |
Kenya_1 |
2018-11-03 |
2018-11-29 |
167 |
#write.csv(dep_out, here::here("database/kenya_data/DeploymentTbl.csv"), row.names = FALSE)
CT Study Table
dep$Location_ID<-str_trim(as.character(dep$Location_ID))
dep$area<-NULL
dep$area[grepl("MN",dep$Location_ID)]<- "MN"
dep$area[grepl("MT",dep$Location_ID)]<- "MT"
dep$area[grepl("NB",dep$Location_ID)]<- "NB"
dep$area[grepl("OMC",dep$Location_ID)]<- "OMC"
dep$SensorType<-"CT"
colnames(dep)<-c("Location", "Camera_ID", "DateOn", "DateOff", "DaysDeployed","Deployment", "Country", "Season", "Area", "SensorType")
kable(head(dep))
| MN02 |
CT160 |
2018-10-20 |
2018-11-13 |
24 |
Kenya_1.1 |
Kenya |
Kenya_1 |
MN |
CT |
| MN04 |
CT157 |
2018-10-21 |
2018-11-02 |
12 |
Kenya_1.1 |
Kenya |
Kenya_1 |
MN |
CT |
| MN05 |
CT162 |
2018-10-20 |
2018-11-13 |
24 |
Kenya_1.1 |
Kenya |
Kenya_1 |
MN |
CT |
| MN06 |
CT161 |
2018-10-20 |
2018-11-13 |
24 |
Kenya_1.1 |
Kenya |
Kenya_1 |
MN |
CT |
| MN07 |
CT159 |
2018-10-20 |
2018-11-13 |
24 |
Kenya_1.1 |
Kenya |
Kenya_1 |
MN |
CT |
| MN08 |
CT158 |
2018-10-28 |
2018-11-15 |
19 |
Kenya_1.1 |
Kenya |
Kenya_1 |
MN |
CT |
#write.csv(dep, here::here("database/kenya_data/SensorStudyTbl.csv"), row.names = FALSE)