Reducing File Size

Section 1: 2016 CDM and USFS Surveyed Area

This section of code reduces the number of columns in the 2016 CMD and USFS Disease Data surveyed area created in Arcmap. In order to accomplish this, the following steps are taken:

  1. The 2016 CMD and USFS Disease Data survey area text file is imported in R (CMD_2016_Clip_SA_join)
  2. Every column expect “TARGET_FID”, “JOIN_FID”, every column originating from the 2016 CMD file created in R, along with the “REGION_ID”, “SURVEY_ID”, legacy data, and source data from the USFS Disease Data file is removed from CMD_2016_Clip_SA_join.
pacman::p_load(pacman, caret, lars, tidyverse, rio)

CMD_2016_Clip_SA_join<-import("C:/Users/Swenson/Documents/R/Denise/GIS/Tables/CDM_2016_Proj_Clip_SA_Join_Table2.txt")
CMD_2016_Clip_SA_join<-CMD_2016_Clip_SA_join[,c(3,4,6:98,100,101,107:111,116,117)]
write.csv(CMD_2016_Clip_SA_join,"C:/Users/Swenson/Documents/R/Denise/GIS/Reduced_Join_Tables/CMD_2016 _Proj_Clip_SA_Join_Table_Reduced.csv")

Section 2: 2016 CDM and USFS Damaged Area

This section of code reduces the number of columns in the 2016 CMD and USFS Disease Data damage area created in Arcmap. In order to accomplish this, the following steps are taken:

  1. The 2016 CMD and USFS Disease Data damage area text file is imported in R (CMD_2016_Clip_DA_join)
  2. Every column expect “TARGET_FID”, “JOIN_FID”, every column originating from the 2016 CMD file created in R, along with the “REGION_ID”, “LABEL”, host columns, DCA columns, damage columns, columns that quanitify damage, “NOTES”, “OBSERVATION_COUNT”, “ACRES”, “SURVEY_ID”, legacy data, and source data from the USFS Disease Data file is removed from CMD_2016_Clip_DA_join.
CMD_2016_Clip_DA_join<-import("C:/Users/Swenson/Documents/R/Denise/GIS/Tables/CDM_2016_Proj_Clip_DA_Join_Table2.txt")
CMD_2016_Clip_DA_join<-CMD_2016_Clip_DA_join[,c(3,4,6:98,104:117,119,120,125,127:135,138,139)]
write.csv(CMD_2016_Clip_DA_join,"C:/Users/Swenson/Documents/R/Denise/GIS/Reduced_Join_Tables/CMD_2016 _Proj_Clip_DA_Join_Table_Reduced.csv")

Section 3: 2017-2018 CDM and USFS Surveyed area

This section of code creates the same type of csv file created in Section 1 for 2017 and 2018. The CMD_SA files contine one less column than the files in Section 1 because there was one FIA tree species in 2016 that was not recorded in 2017 or 2018.

years_17_18<-c("2017","2018")
for(i in 1:length(years_17_18)){
  CMD_SA<-import(paste("C:/Users/Swenson/Documents/R/Denise/GIS/Tables/CDM_",years_17_18[i],"_Proj_Clip_SA_Join_Table2.txt",sep=""))
  CMD_SA<-CMD_SA[,c(3,4,6:97,99,100,106:110,115,116)]
  setwd("C:/Users/Swenson/Documents/R/Denise/GIS/Reduced_Join_Tables")
  write.csv(CMD_SA,paste("CMD_",years_17_18[i],"_Proj_Clip_SA_Join_Table_Reduced.csv"))
}

Section 4: 2017-2018 CDM and USFS Damaged area

This section of code creates the same type of csv file created in Section 2 for 2017 and 2018. The CMD_DA files contine one less column than the file in Section 2 because there was one FIA tree species in 2016 that was not recorded in 2017 or 2018.

for(i in 1:length(years_17_18)){
  CMD_DA<-import(paste("C:/Users/Swenson/Documents/R/Denise/GIS/Tables/CDM_",years_17_18[i],"_Proj_Clip_DA_Join_Table2.txt",sep=""))
  CMD_DA<-CMD_DA[,c(3,4,6:97,103:116,118,119,124,126:134,137,138)]
  setwd("C:/Users/Swenson/Documents/R/Denise/GIS/Reduced_Join_Tables")
  write.csv(CMD_DA,paste("CMD_",years_17_18[i],"_Proj_Clip_DA_Join_Table_Reduced.csv"))
}

Section 5: USFS Damaged Points and USFS Surveyed/Damaged area

This section of code reduces the number of columns in the USFS Disease Data damaged points and USFS surveyed/damaged area created in Arcmap. In order to accomplish this, the following steps are taken:

  1. The 2016 CMD and USFS Disease Data damage area text file is imported in R (The Dpts)
  2. Only the columns originating from the USFS Disease Data damaged points file downloaded from the USFS website are preserved in The Dpts.
  3. This process is repeated for each USFS surveyed/damaged area (“DA” and “SA”) per year.
years<-c("2016","2017","2018")
file_type<-c("SA","DA")
for(i in 1:length(years)){
  for(j in 1:length(file_type)){
    Dpts<-import(paste("C:/Users/Swenson/Documents/R/Denise/GIS/Tables/Dpts_",years[i],"_Clip_",file_type[j],"_Join_Table2.txt",sep=""))
    Dpts<-Dpts[,c(3,4,10,12:23,26:29,31,34:35)]
    setwd("C:/Users/Swenson/Documents/R/Denise/GIS/Reduced_Join_Tables")
    write.csv(Dpts,paste("Dpts_",years[i],"_Clip_",file_type[j],"_Join_Table_Reduced.csv",sep=""))
  }
}