From fb9757dfe53544d38307d8752e4dba6ae9cec2dc Mon Sep 17 00:00:00 2001 From: kyle-messier Date: Fri, 26 Apr 2024 09:28:19 -0400 Subject: [PATCH] olm hard code paths --- .Rhistory | 355 +------------------- _targets.R | 349 +++++++++++++------ _targets/meta/meta | 165 +++++---- code/02_Geographic_Covariates/Calc_OLM.R | 156 ++------- code/03_Pesticide_Analysis/Target_Helpers.R | 17 +- 5 files changed, 377 insertions(+), 665 deletions(-) diff --git a/.Rhistory b/.Rhistory index 0fbff4c..1d722e2 100755 --- a/.Rhistory +++ b/.Rhistory @@ -1,357 +1,3 @@ -g1 -tar_visnetwork(targets_only = T) -tar_make() -tar_make() -tar_visnetwork(targets_only = T) -library(parsnip) -?fit -sf_outcomes -pest_data <- data.frame( -y1 = rnorm(100), # Example response variable 1 -y2 = rnorm(100), # Example response variable 2 -x1 = rnorm(100), # Example predictor variable 1 -x2 = rnorm(100) # Example predictor variable 2 -) -# Fit using the linear_model function in Parsnip -lasso <- linear_reg() %>% -set_engine("glmnet", family = "mgaussian") %>% -set_mode("regression") %>% -fit(cbind(y1, y2) ~ ., data = pest_data) -pest_data <- data.frame( -y1 = rnorm(100), # Example response variable 1 -y2 = rnorm(100), # Example response variable 2 -x1 = rnorm(100), # Example predictor variable 1 -x2 = rnorm(100) # Example predictor variable 2 -) -pest_data -a <- cbind(y1, y2) -y1 = rnorm(100), # Example response variable 1 -y1 = rnorm(100) -y2 = rnorm(100) -a <- cbind(y1, y2) -dim(a) -a -?glmnet -df -pest_data <- df |> -select(c("cncntrt","Year","left_cns")) -df -df -pest_data <- df |> -select(c("cncntrt","Year","lft_cns")) -pest_data -# Fit using the linear_model function in Parsnip -lasso <- linear_reg() %>% -set_engine("glmnet", family = "gaussian") %>% -set_mode("regression") %>% -fit(cncntrt ~ ., data = pest_data) -pest_data <- data.frame( -y1 = rnorm(100), # Example response variable 1 -y2 = rnorm(100), # Example response variable 2 -x1 = rnorm(100), # Example predictor variable 1 -x2 = rnorm(100) # Example predictor variable 2 -) -# Fit using the linear_model function in Parsnip -lasso <- linear_reg() %>% -set_engine("glmnet", family = "mgaussian") %>% -set_mode("regression") %>% -fit(cbind(y1, y2) ~ ., data = pest_data) -# Fit using the linear_model function in Parsnip -lasso <- linear_reg(penalty = 1) %>% -set_engine("glmnet", family = "mgaussian") %>% -set_mode("regression") %>% -fit(cbind(y1, y2) ~ ., data = pest_data) -lasso -lasso$fit -lasso$fit$beta -data_partitioned <- tar_read(sf_pesticide_partition_cleaned) -data_partitioned[[1]] -data_partitioned[[2]] -data_partitioned[[2]][,l10n_info()] -data_partitioned[[2]][,1:10] -data_partitioned[[2]][,1:5] -data_partitioned[[1]] -data_outcome <- data_partitioned[[1]] |> -st_drop_geometry() -data_outcome -data_model <- left_join(data_outcome, data_covariates, by = "id") -data_covariates <- data_partitioned[[2]] |> -st_drop_geometry() -data_model <- left_join(data_outcome, data_covariates, by = "id") -data_model -data_model[,1:5] -data_model[,1:10] -data <- left_join(data_outcome, data_covariates, by = "id") -data -data_covariates -colnames(data_covariates) -colnames(data_covariates)[1:20] -data_outcome -data_outcome_to_join <- data_outcome |> -st_drop_geometry() |> -filter("cncntrt","id") |> -as.data.frame() |> -mutate(id = row_number()) -data_outcome_to_join <- data_outcome |> -st_drop_geometry() |> -select(c("cncntrt","id")) |> -as.data.frame() |> -mutate(id = row_number()) -data_outcome_to_join -data_outcome_to_join |> head() -data_covariates -colnames(data_covariates)[1:10] -colnames(data_covariates)[1790:1803] -data_covariates_to_join <- data_covariates |> -st_drop_geometry() |> -select(-"geometry") |> -as.data.frame() |> -mutate(id = row_number()) -data_covariates <- sf_pesticide_partition_cleaned[[2]] -data_covariates_to_join <- data_covariates |> -st_drop_geometry() |> -select(-"geometry") |> -as.data.frame() |> -mutate(id = row_number()) -data_covariates_to_join <- data_covariates |> -st_drop_geometry() |> -as.data.frame() |> -mutate(id = row_number()) -View(data_covariates_to_join) -data_fit <- left_join(data_outcome_to_join, data_covariates_to_join, by = "id") -View(data_fit) -data_fit <- left_join(data_outcome_to_join, data_covariates_to_join, by = "id") |> -select(-"id") -View(data_fit) -hist(data_fit$cncntrt) -summary(data_fit$cncntrt) -data_outcome -data_outcome[data_outcome$cncntrt==0,] -d1 <- tar_read(readQS) -d1 -d1[d1$cncntrt==0,] -p1<-d1[d1$cncntrt==0,] -p1$X -p1$Y -p1[c("X","Y")] -p1 -azo <- st_read("/Volumes/SET/Projects/PrestoGP_Pesticides/input/data_process/data_AZO_watershed_huc_join.shp") -azo -azo.idx <- azo[azo$cncntrt==0,] -azo.idx -azo.initial <- load("/Volumes/SET/Projects/PrestoGP_Pesticides/input/data_process/data_AZO_year_avg.RData") -azo.initial -azo.initial[[1]] -load("/Volumes/SET/Projects/PrestoGP_Pesticides/input/data_process/data_AZO_year_avg.RData") -data.AZO.year.avg -data.AZO.year.avg[data.AZO.year.avg$concentration==0,] -sf_pesticide_partition_cleaned[[3]] -sf_pesticide_partition_cleaned[[3]]$wll_dpt -knitr::opts_chunk$set(echo = TRUE) -library(dataRetrieval) -install.packages("dataRetrieval") -library(dataRetrieval) -library(dplyr) -library(beepr) -install.packages("beepr") -library(dataRetrieval) -library(dplyr) -library(beepr) -library(lubridate) -library(tidyverse) -library(data.table) -param.chlorotriazines <- c("39632", "04040", "04038", "04039", "38535", "04035") -startDate <- "2000-01-01" -endDate <- "2022-12-31" -state.list <- state.abb[c(-2, -11)] -state.fun.AZO <- function(x) { -print(x) -temp <- whatWQPdata( -statecode = state.list[x], -parameterCd = param.chlorotriazines -) -temp <- temp[temp$MonitoringLocationTypeName == "Well", ] -if (nrow(temp) > 0) { -site.info <- str_subset(temp$MonitoringLocationIdentifier, "(?<=USGS-)\\d+") %>% -str_extract("(?<=USGS-)\\d+") %>% -readNWISsite() %>% -select(c(site_no, well_depth_va)) -site.info$MonitoringLocationIdentifier <- paste0("USGS-", site.info$site_no) -data.chlorotriazines <- readWQPqw(temp$MonitoringLocationIdentifier, param.chlorotriazines, -startDate = startDate, endDate = endDate -) -result <- left_join(data.chlorotriazines, temp, by = "MonitoringLocationIdentifier") %>% -left_join(site.info, by = "MonitoringLocationIdentifier") -return(result) -} -} -data.AZO <- lapply(1:48, state.fun.AZO) -sum(is.na(sf_pesticide_partition_cleaned[[3]]$wll_dpt)) -dim(d1) -dim(d1,1) -dim(d1)[1] -dim(d1)[1]-6 -tar_make() -p1 <- tar_read(plot_pesticide_maps_57fe39ed) -p1 -sf_pesticide_partition_cleaned <- tar_read(sf_pesticide_partition_cleaned) -sf_pesticide_partition_cleaned[[1]] -ggplot(sf_pesticide_partition_cleaned,aes(cncntrt)) + geom_density() -ggplot(sf_pesticide_partition_cleaned |> as.data.frame(),aes(cncntrt)) + geom_density() -ggplot(sf_pesticide_partition_cleaned |> as.data.frame(),aes(cncntrt)) + geom_density() + scale_x_log10() -library(PrestoGP) -?VecchiaModel -?check_input -?PrestoGP::check_input -?PrestoGP::prestogp_fit -?MultivariateVecchiaModel -tar_make() -tar_make() -sf_pesticide_dummies_cv <- tar_read(sf_pesticide_dummies_cv) -sf_pesticide_dummies_cv[[1]] -sf_pesticide_dummies_cv -length(sf_pesticide_dummies_cv) -sf_pesticide_dummies_cv[[1]] -tar_make() -sf_pesticide_dummies_cv[[1]] -sf_pesticide_dummies_cv[[1]]$kfolds -?tar_group_by -tar_make() -tar_make() -sf_pesticide_for_fit <- tar_read(sf_pesticide_for_fit) -sf_pesticide_for_fit -sf_pesticide_for_fit[,1:10] -head(sf_pesticide_for_fit) -View(sf_pesticide_for_fit) -tar_make() -lasso.fit <- tar_read(lasso_fit_by_chem_4eeee620) -lasso.fit$censor_probs -?glmnet -lasso.fit$fit$beta -plot(lasso.fit$fit) -plot(lasso.fit$fit$beta) -plot(lasso.fit$fit) -lasso.fit$lvl -glmnet::plot(lasso.fit$fit) -tar_visnetwork(targets_only = T) -tar_make() -lasso.fit <- tar_read(lasso_fit_by_chem_4eeee620) -autoplot(lasso.fit) -autoplot(lasso.fit$fit) -lasso.fit -autoplot(lasso.fit) -autoplot(lasso.fit$spec) -lasso.fit$fit -tar_make() -f2 <- tar_read(lasso_fit_by_kfold_2808dfa1) -f2 -f2[[1]] -f2[[2]] -f2[[3]] -f2[[4]] -plot(f2) -plot(f2[[2]]) -f2 -autoplot(f2) -autoplot(f2$fit) -tar_make() -f1 <- tar_read(lasso_fit_by_kfold_68b90cee) -f1 -autoplot(f1) -autoplot(f1$fit) -plot(f1$fit) -tar_visnetwork(targets_only = T) -?tar_visnetwork -tar_mermaid(targets_only = T) -tm <- tar_mermaid(targets_only = T) -tm -tar_visnetwork(targets_only = T) -tar_visnetwork() -tar_make() -m1 <- tar_read(plot_covariate_maps_97adc691) -m1 -1259*24 -1259*24/2 -======= -group_by(ChmclNm) |> -nest() |> -mutate(data = map(data, ~ ifelse(.x$lft_cns == 0, .x$cncntrt, 1e-9))) |> -pull(data) -# 2) A list of LOD, each element is a vector of the limit of detection -# use dplyr to create a separate list by each ChmlNm and create an LOD. The -# LOD should be the cnctrnt -pesticide_lod <- data_analysis |> -group_by(ChmclNm) |> -nest() |> -mutate(data = map(data, ~ .x$cnctrnt)) |> -pull(data) -# 2) A list of LOD, each element is a vector of the limit of detection -# use dplyr to create a separate list by each ChmlNm and create an LOD. The -# LOD should be the cnctrnt -pesticide_lod <- data_analysis |> -group_by(ChmclNm) |> -nest() |> -mutate(data = map(data, ~ .x$cncntrt)) |> -pull(data) -pesticide_outcomes[[1]][1:10] -pesticide_lod[[1]][1:10] -#2a) Create a list of the of the lft_cns variable by ChmclNm -pesticide_lft_cns <- data_analysis |> -group_by(ChmclNm) |> -nest() |> -mutate(data = map(data, ~ .x$lft_cns)) |> -pull(data) -pesticide_lft_cns[[1]][1:10] -cbind(pesticide_lft_cns[[1]][1:10],pesticide_outcomes[[1]][1:10],pesticide_lod[[1]][1:10]) -# 4) A list of X's, each element is a matrix of the covariates -# For now, we will use the covariates in the data_analysis -pesticide_covariates <- data_analysis |> -group_by(ChmclNm) |> -nest() |> -mutate(data = map(data, ~ .x %>% select(-cncntrt, -lft_cns))) |> -pull(data) -pesticide_covariates[[1]] -pesticide_covariates[[2]] -pesticide_covariates[[3]] -pesticide_covariates[[4]] -ls -pesticide_covariates[[3]] -data_analysis -data_analysis[[1]][,1:20] -data_analysis[[1]][,1:10] -data_analysis[,1:10] -# 5) A list of locs, each element is a matrix of the locations -# For now, we will use the locations in the data_analysis - it includes x, y, and time -# Because the locations are from the sf geometry object we need to use the original data -# We get the geometry from the sf object and then add the time (column name is Year) -pesticide_locs <- data_analysis |> -group_by(ChmclNm) |> -nest() |> -mutate(data = map(data, ~ st_coordinates(.x |> select(geometry)))) |> -pull(data) -# 5) A list of locs, each element is a matrix of the locations -# For now, we will use the locations in the data_analysis - it includes x, y, and time -# Because the locations are from the sf geometry object we need to use the original data -# We get the geometry from the sf object and then add the time (column name is Year) -data_analysis <- splits |> -analysis() |> -group_by(ChmclNm) |> -nest() |> -mutate(geometry = st_as_text(geometry)) |> -sf::st_drop_geometry() -# 5) A list of locs, each element is a matrix of the locations -# For now, we will use the locations in the data_analysis - it includes x, y, and time -# Because the locations are from the sf geometry object we need to use the original data -# We get the geometry from the sf object and then add the time (column name is Year) -data_analysis <- splits |> -analysis() |> -group_by(ChmclNm) |> -nest() |> -mutate(data = map(data, st_coordinates())) |> -sf::st_drop_geometry() -data_analysis <- splits |> -analysis() |> -group_by(ChmclNm) data_analysis <- splits |> analysis() data_analysis @@ -863,3 +509,4 @@ library(yardstick) library(data.table) tar_visnetwork(targets_only = T) getwd() +getwd() diff --git a/_targets.R b/_targets.R index 2744b05..058e648 100644 --- a/_targets.R +++ b/_targets.R @@ -23,12 +23,13 @@ library(spatialsample) library(broom) library(yardstick) library(data.table) +library(exactextractr) # Set target options: tar_option_set( packages = c("PrestoGP","tibble","sf","terra","qs","tidyverse","skimr", "rsample","stats","ggplot2","tarchetypes","parsnip","fastDummies", "scales","ggridges","spatialsample","broom","yardstick","data.table", - "nhdplusTools"), + "nhdplusTools","exactextractr"), format = "qs", sf_use_s2(FALSE), # @@ -37,18 +38,18 @@ tar_option_set( # Choose a controller that suits your needs. For example, the following # sets a controller with 2 workers which will run as local R processes: # - #controller = crew::crew_controller_local(workers = 2) + # controller = crew::crew_controller_local(workers = 6) # # - controller = crew.cluster::crew_controller_slurm( - workers = 12, - # Many clusters install R as an environment module, and you can load it - # with the script_lines argument. To select a specific verison of R, - # you may need to include a version string, e.g. "module load R/4.3.0". - # Check with your system administrator if you are unsure. - script_lines = "module load R", - slurm_partition = "geo" - ) + # controller = crew.cluster::crew_controller_slurm( + # workers = 12, + # # Many clusters install R as an environment module, and you can load it + # # with the script_lines argument. To select a specific verison of R, + # # you may need to include a version string, e.g. "module load R/4.3.0". + # # Check with your system administrator if you are unsure. + # script_lines = "module load R", + # slurm_partition = "geo" + # ) # # # Set other options as needed. @@ -71,9 +72,10 @@ tar_source(c("code/03_Pesticide_Analysis/Target_Helpers.R", # data_AZO_covariates_cleaned_03032024 # The TARGET LIST list( - tar_target(# This target downloads the WBD database (WARNING LARGE) + tar_target(# This target is the WBD database name = wbd_data, - command = download_wbd(outdir = "input/WBD-National/") + command = "input/wmd_national/WBD_National_GDB/WBD_National_GDB.gdb", + format = "file" ), list( # Dynamic branch of the states for pesticide data from NWIS tar_target( @@ -109,70 +111,195 @@ list( tar_target( # This target re-projects the data into an sf object name = sf_pesticide, # use st_sf to create an sf object with the Albers Equal Area projection - command = st_as_sf(pesticide_yearly_filtered, coords = c("Longitude","Latitude"), crs = 5070) + command = st_as_sf(pesticide_yearly_filtered, coords = c("Longitude","Latitude"), crs = 4326) ), tar_target( # This target joins the point pesticide data with HUC data name = sf_pesticide_huc, - command = join_pesticide_huc(sf_pesticide) + command = join_pesticide_huc(sf_pesticide, wbd_data) ), - tar_target( # This target separates the data into (1)outcome (2) covariates/features (3) ancillary info - name = sf_pesticide_partition, - command = partition_datasets(sf_pesticide) - ), - tar_target( # This target runs skimr::skim to look at the summary stats - name = explore_skim, - command = skim(sf_pesticide_partition[[1]]) #List element 2 is the covariates + tar_target( + olm_bulk_density_files, + unlist(list.files("/Volumes/set/Projects/PrestoGP_Pesticides/input/OpenLandMapData/Bulk_Density/",pattern = "*.tif",full.names = TRUE)) ), - tar_target( # This target makes a ridge density plot of the outcomes - name = plot_outcome_ridgelines, - command = plot_pesticide_ridges(sf_pesticide_partition[[1]]) #List element 1 is the Pesticide data - ), - tar_target(# This target prepares the numeric and factor covariates for analysis - name = sf_pesticide_partition_cleaned, - command = covariate_prep(sf_pesticide_partition, 0.00001) - ), - tar_target( # This target pivots the covariates - name = sf_covariates_pivot, - command = pivot_covariates(sf_pesticide_partition_cleaned[[1]]) - ), - list( # Dynamic branching with tar_group_by and plotting covariates - tar_group_by( - sf_explore_cov_maps, - sf_covariates_pivot, - covariate - ), - tar_target( - plot_covariate_maps, - plot_exploratory_covariates(sf_explore_cov_maps), - pattern = map(sf_explore_cov_maps), - iteration = "list" + tar_target(# These targets are the raw OLM files + name = olm_bulk_density_crop, + command = olm_read_crop(olm_bulk_density_files), + format = tar_format( + read = function(path) terra::rast(path), + write = function(object, path) terra::writeRaster(x = object, filename = path, filetype = "GTiff", overwrite = TRUE), + marshal = function(object) terra::wrap(object), + unmarshal = function(object) terra::unwrap(object) ) ), - list( # Dynamic branching with tar_group_by and plotting maps of pesticide outcome - tar_group_by( - sf_plot_outcome_maps, - sf_pesticide_partition_cleaned[[1]], - ChmclNm - ), - tar_target( - plot_pesticide_maps, - plot_outcome_map(sf_plot_outcome_maps), - pattern = map(sf_plot_outcome_maps), - iteration = "list" + tar_target( + olm_pH_files, + unlist(list.files("/Volumes/set/Projects/PrestoGP_Pesticides/input/OpenLandMapData/pH/",pattern = "*.tif",full.names = TRUE)) + ), + tar_target(# These targets are the raw OLM files + name = olm_pH_crop, + command = olm_read_crop(olm_pH_files), + format = tar_format( + read = function(path) terra::rast(path), + write = function(object, path) terra::writeRaster(x = object, filename = path, filetype = "GTiff", overwrite = TRUE), + marshal = function(object) terra::wrap(object), + unmarshal = function(object) terra::unwrap(object) + ) + ), + tar_target( + olm_clay_files, + unlist(list.files("/Volumes/set/Projects/PrestoGP_Pesticides/input/OpenLandMapData/Clay_Content/",pattern = "*.tif",full.names = TRUE)) + ), + tar_target(# These targets are the raw OLM files + name = olm_clay_crop, + command = olm_read_crop(olm_clay_files), + format = tar_format( + read = function(path) terra::rast(path), + write = function(object, path) terra::writeRaster(x = object, filename = path, filetype = "GTiff", overwrite = TRUE), + marshal = function(object) terra::wrap(object), + unmarshal = function(object) terra::unwrap(object) + ) + ), + tar_target( + olm_oc_files, + unlist(list.files("/Volumes/set/Projects/PrestoGP_Pesticides/input/OpenLandMapData/Organic_Carbon/",pattern = "*.tif",full.names = TRUE)) + ), + tar_target(# These targets are the raw OLM files + name = olm_oc_crop, + command = olm_read_crop(olm_oc_files), + format = tar_format( + read = function(path) terra::rast(path), + write = function(object, path) terra::writeRaster(x = object, filename = path, filetype = "GTiff", overwrite = TRUE), + marshal = function(object) terra::wrap(object), + unmarshal = function(object) terra::unwrap(object) ) - ), - tar_target( # This target creates 10-fold CV using Spatialsample - name = spatial_kfold, - command = spatial_block_cv(sf_pesticide_partition_cleaned[[1]]) - ), - tar_target( # This target plots the CV folds - name = plot_spatial_kfolds, - command = autoplot(spatial_kfold) - ), - tar_target( # This target creates leave-one-year-out cross-validatoin - name = temporal_kfold, - command = group_vfold_cv(sf_pesticide_partition_cleaned[[1]], group = "Year") ), + tar_target( + olm_sand_files, + unlist(list.files("/Volumes/set/Projects/PrestoGP_Pesticides/input/OpenLandMapData/Sand_Content/",pattern = "*.tif",full.names = TRUE)) + ), + tar_target(# These targets are the raw OLM files + name = olm_sand_crop, + command = olm_read_crop(olm_sand_files), + format = tar_format( + read = function(path) terra::rast(path), + write = function(object, path) terra::writeRaster(x = object, filename = path, filetype = "GTiff", overwrite = TRUE), + marshal = function(object) terra::wrap(object), + unmarshal = function(object) terra::unwrap(object) + ) + ), + tar_target( + olm_soil_order_files, + unlist(list.files("/Volumes/set/Projects/PrestoGP_Pesticides/input/OpenLandMapData/Soil_Order/",pattern = "*.tif",full.names = TRUE)) + ), + tar_target(# These targets are the raw OLM files + name = olm_soil_order_crop, + command = olm_read_crop(olm_soil_order_files), + format = tar_format( + read = function(path) terra::rast(path), + write = function(object, path) terra::writeRaster(x = object, filename = path, filetype = "GTiff", overwrite = TRUE), + marshal = function(object) terra::wrap(object), + unmarshal = function(object) terra::unwrap(object) + ) + ), + tar_target( + olm_texture_files, + unlist(list.files("/Volumes/set/Projects/PrestoGP_Pesticides/input/OpenLandMapData/USDA_Texture_Class/",pattern = "*.tif",full.names = TRUE)) + ), + tar_target(# These targets are the raw OLM files + name = olm_texture_crop, + command = olm_read_crop(olm_texture_files), + format = tar_format( + read = function(path) terra::rast(path), + write = function(object, path) terra::writeRaster(x = object, filename = path, filetype = "GTiff", overwrite = TRUE), + marshal = function(object) terra::wrap(object), + unmarshal = function(object) terra::unwrap(object) + ) + ), + tar_target( + olm_combined, + command = c(olm_bulk_density_crop, olm_pH_crop, olm_clay_crop, olm_oc_crop, olm_sand_crop, olm_soil_order_crop, olm_texture_crop), + format = tar_format( + read = function(path) terra::rast(path), + write = function(object, path) terra::writeRaster(x = object, filename = path, filetype = "GTiff", overwrite = TRUE), + marshal = function(object) terra::wrap(object), + unmarshal = function(object) terra::unwrap(object) + ) + ) + # tar_target( + # olm_bulk_density_rast, + # command = terra::rast(olm_bulk_density) + # ) + # tar_target( + # olm_pH_files, + # unlist(list.files("/Volumes/set/Projects/PrestoGP_Pesticides/input/OpenLandMapData/pH",pattern = "*.tif",full.names = TRUE)) + # ), + # tar_target(# These targets are the raw OLM files + # name = olm_pH, + # command = olm_read_crop(olm_pH_files), + # pattern = map(olm_pH_files) + ) + # tar_target( # This target separates the data into (1)outcome (2) covariates/features (3) ancillary info + # name = sf_pesticide_partition, + # command = partition_datasets(sf_pesticide) + # ), + # tar_target( # This target runs skimr::skim to look at the summary stats + # name = explore_skim_outcomes, + # command = skim(sf_pesticide) + # ), + # tar_target( # This target runs skimr::skim to look at the summary stats + # name = explore_skim_covariates, + # command = skim(sf_covariates) + # ), + # tar_target( # This target makes a ridge density plot of the outcomes + # name = plot_outcome_ridgelines, + # command = plot_pesticide_ridges(sf_pesticide_partition[[1]]) #List element 1 is the Pesticide data + # ), + # tar_target(# This target prepares the numeric and factor covariates for analysis + # name = sf_pesticide_partition_cleaned, + # command = covariate_prep(sf_pesticide_partition, 0.00001) + # ), + # tar_target( # This target pivots the covariates + # name = sf_covariates_pivot, + # command = pivot_covariates(sf_pesticide_partition_cleaned[[1]]) + # ), + # list( # Dynamic branching with tar_group_by and plotting covariates + # tar_group_by( + # sf_explore_cov_maps, + # sf_covariates_pivot, + # covariate + # ), + # tar_target( + # plot_covariate_maps, + # plot_exploratory_covariates(sf_explore_cov_maps), + # pattern = map(sf_explore_cov_maps), + # iteration = "list" + # ) + # ), + # list( # Dynamic branching with tar_group_by and plotting maps of pesticide outcome + # tar_group_by( + # sf_plot_outcome_maps, + # sf_pesticide_partition_cleaned[[1]], + # ChmclNm + # ), + # tar_target( + # plot_pesticide_maps, + # plot_outcome_map(sf_plot_outcome_maps), + # pattern = map(sf_plot_outcome_maps), + # iteration = "list" + # ) + # ), + # tar_target( # This target creates 10-fold CV using Spatialsample + # name = spatial_kfold, + # command = spatial_block_cv(sf_pesticide_partition_cleaned[[1]]) + # ), + # tar_target( # This target plots the CV folds + # name = plot_spatial_kfolds, + # command = autoplot(spatial_kfold) + # ), + # tar_target( # This target creates leave-one-year-out cross-validatoin + # name = temporal_kfold, + # command = group_vfold_cv(sf_pesticide_partition_cleaned[[1]], group = "Year") + # ), # list( # Dynamic branching with tar_group_by and fitting lasso model to each pesticide group # tar_group_by( # sf_lasso_mvn, @@ -186,50 +313,50 @@ list( # iteration = "list" # ) # ), - tar_target( - kfolds_iter, - 1:10 - ), - tar_target( - get_spatial_kfolds, - get_rsplit(spatial_kfold, kfolds_iter), - pattern = map(kfolds_iter), - ), - tar_target( - lasso_fit_spatial_kfold, - lasso_spatial_kfold_fit(get_spatial_kfolds, as.formula(log(cncntrt) ~ . -id - ChmclNm - Year -lft_cns)), - pattern = map(get_spatial_kfolds), - iteration = "list" - ), - tar_target(# This target will create a small subsample of the data for testing the PrestoGP model - name = sub_sample_data, - command = dplyr::filter(sf_pesticide_partition_cleaned[[1]],Year >= 2003 & Year <= 2004) + # tar_target( + # kfolds_iter, + # 1:10 + # ), + # tar_target( + # get_spatial_kfolds, + # get_rsplit(spatial_kfold, kfolds_iter), + # pattern = map(kfolds_iter), + # ), + # tar_target( + # lasso_fit_spatial_kfold, + # lasso_spatial_kfold_fit(get_spatial_kfolds, as.formula(log(cncntrt) ~ . -id - ChmclNm - Year -lft_cns)), + # pattern = map(get_spatial_kfolds), + # iteration = "list" + # ), + # tar_target(# This target will create a small subsample of the data for testing the PrestoGP model + # name = sub_sample_data, + # command = dplyr::filter(sf_pesticide_partition_cleaned[[1]],Year >= 2003 & Year <= 2004) + # + # ), + # tar_target( # This target creates 10-fold CV using Spatialsample + # name = sub_sp_kfold, + # command = spatial_block_cv(sub_sample_data, v = 3) + # ), + # tar_target( # This target creates leave-one-year-out cross-validatoin + # name = sub_time_kfold, + # command = group_vfold_cv(sub_sample_data, group = "Year") + # ), + # tar_target( + # kfolds_iter3, + # 1:3 + # ), + # tar_target( + # get_sub_sp_kfolds, + # get_rsplit(sub_sp_kfold, kfolds_iter3), + # pattern = map(kfolds_iter3), + # ), + # tar_target( + # PrestoGP_sub_fit, + # fit_MV_Vecchia(get_sub_sp_kfolds), + # pattern = map(get_sub_sp_kfolds), + # iteration = "list" + # ) - ), - tar_target( # This target creates 10-fold CV using Spatialsample - name = sub_sp_kfold, - command = spatial_block_cv(sub_sample_data, v = 3) - ), - tar_target( # This target creates leave-one-year-out cross-validatoin - name = sub_time_kfold, - command = group_vfold_cv(sub_sample_data, group = "Year") - ), - tar_target( - kfolds_iter3, - 1:3 - ), - tar_target( - get_sub_sp_kfolds, - get_rsplit(sub_sp_kfold, kfolds_iter3), - pattern = map(kfolds_iter3), - ), - tar_target( - PrestoGP_sub_fit, - fit_MV_Vecchia(get_sub_sp_kfolds), - pattern = map(get_sub_sp_kfolds), - iteration = "list" - ) -) # Created by use_targets(). # 3. Run PrestoGP model on local machine for small test case # 3a. Target for the model results 3b. Target for the model metrics diff --git a/_targets/meta/meta b/_targets/meta/meta index 45f6c09..2235e5b 100644 --- a/_targets/meta/meta +++ b/_targets/meta/meta @@ -1,10 +1,12 @@ name|type|data|command|depend|seed|path|time|size|bytes|format|repository|iteration|parent|children|seconds|warnings|error -.Random.seed|object|5080cfe2ad70b87d||||||||||||||| +.Random.seed|object|c2e01d2a8ff9ee66||||||||||||||| +calc_olm|function|f6964f4b260356a3||||||||||||||| combine_state_data|function|7df828cef5aac723||||||||||||||| coords_mat|stem|29a93bd67ca78c5f|503df07fba4d9a96|337c5f07b878144a|-1325898640||t19810.6691524591s|31da326e08ce3bbc|480689|qs|local|vector|||0.002|| covariate_prep|function|c9eca70c452240cc||||||||||||||| create_dummies|stem|9967dc623a964f93|adf287298fe34b32|40cbe923fa64cbd2|1525017976||t19807.803751512s|a99a8404db22efe7|175250|qs|local|vector|||2.99|| create_dummy_vars|function|e46493e1d28e291b||||||||||||||| +create_olm_combined|function|2a0af497a54abfd2||||||||||||||| drop_bad_cols|function|8336546cb99c9058||||||||||||||| drop_cols|stem|457320163977a1f5|912c35726ac745c3|d35f616ce2d80810|1706491127||t19807.8037533784s||94022|qs|local|vector|||0.044||Cant subset columns past the end.1m22m36mℹ39m Location 882 doesnt exist.36mℹ39m There are only 881 columns. explore_outcome_maps|pattern|b6d678946dc95b50|867964fdb073d848||1038930678||||9565918|qs|local|list||explore_outcome_maps_b1f35340*explore_outcome_maps_a2d84b6a*explore_outcome_maps_b04ba7d9*explore_outcome_maps_51ac62ab*explore_outcome_maps_1843c324*explore_outcome_maps_f140183a|0.172|| @@ -45,7 +47,7 @@ get_sub_sp_kfolds_cde67306|branch|640dc78efbb0e3a9|99d6d99a185ad521|569704226b05 get_unique_covariates|stem|aa833406e9ef1440|141aeed9c1e94e70|12797004ff525ee3|1128749230||t19808.5914536071s|2c9e502661ecd32d|146831|qs|local|vector|||1.029|| get_yearly_average|function|85fec8feff4be03b||||||||||||||| get_yearly_averages|function|85fec8feff4be03b||||||||||||||| -join_pesticide_huc|function|5fbe9c12eb8cc295||||||||||||||| +join_pesticide_huc|function|69639db1e5419739||||||||||||||| kfold_cv|stem|9ce87fb23134293b|1d4ab837ec57d902|e59c9f0d8be4a2fd|-1865240154||t19810.6691611835s|51865c8346c060c0|7702|qs|local|vector|||0.013|| kfolds_iter|stem|d86e8c057082e00b|a2f087abc972c6e3|ef46db3751d8e999|-841571486||t19828.7453813849s|7e02ad38317bcde4|55|qs|local|vector||kfolds_iter_ccba877f*kfolds_iter_084b9b29*kfolds_iter_91e9ed7e*kfolds_iter_0af15e67*kfolds_iter_06d3c0ed*kfolds_iter_280e29c8*kfolds_iter_37587497*kfolds_iter_ad604bd2*kfolds_iter_320243db*kfolds_iter_9641ec09|0.001|| kfolds_iter3|stem|944204653e8e9b56|d2be359edfeb6802|ef46db3751d8e999|1346903058||t19829.5864680691s|ded833868582137a|50|qs|local|vector||kfolds_iter3_ccba877f*kfolds_iter3_084b9b29*kfolds_iter3_91e9ed7e|0|| @@ -85,12 +87,30 @@ lasso_fit_spatial_kfold_d1f0d4d5|branch|b704de897b767c38|4fc110553339911e|899292 lasso_fit_spatial_kfold_fbc4a657|branch|482bc3c6259f7d36|4fc110553339911e|59b0576546c12cb4|-1586957779||t19828.8274287661s|6ef2312f907bf027|6763444|qs|local|list|lasso_fit_spatial_kfold||77.099|| lasso_fit_spatial_kfold_ff3826ac|branch|4dcb95397cba88d1|4fc110553339911e|3a4b53b3a27d2a69|-2068886761||t19828.8295894503s|10b98553f767385c|5069111|qs|local|list|lasso_fit_spatial_kfold||100.752|| lasso_spatial_kfold_fit|function|db2c7bfd885d9600||||||||||||||| +olm_bulk_density|stem|9ad1287adc12bc24|f663930a8e8c28d5|0e7d3bf9dd03f011|-746613225||t19836.6275598268s|cd757cc8851bd97d|947659674|format_custom&read=ZnVuY3Rpb24gKHBhdGgpIAp0ZXJyYTo6cmFzdChwYXRoKQ&write=ZnVuY3Rpb24gKG9iamVjdCwgcGF0aCkgCnRlcnJhOjp3cml0ZVJhc3Rlcih4ID0gb2JqZWN0LCBmaWxlbmFtZSA9IHBhdGgsIGZpbGV0eXBlID0gIkdUaWZmIiwgCiAgICBvdmVyd3JpdGUgPSBUUlVFKQ&marshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp3cmFwKG9iamVjdCk&unmarshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp1bndyYXAob2JqZWN0KQ&convert=©=&repository=|local|vector|||120.975|| +olm_bulk_density_crop|stem|a61f5474c6059fd3|f663930a8e8c28d5|0e7d3bf9dd03f011|-293045127||t19836.6515527408s|cd757cc8851bd97d|947659674|format_custom&read=ZnVuY3Rpb24gKHBhdGgpIAp0ZXJyYTo6cmFzdChwYXRoKQ&write=ZnVuY3Rpb24gKG9iamVjdCwgcGF0aCkgCnRlcnJhOjp3cml0ZVJhc3Rlcih4ID0gb2JqZWN0LCBmaWxlbmFtZSA9IHBhdGgsIGZpbGV0eXBlID0gIkdUaWZmIiwgCiAgICBvdmVyd3JpdGUgPSBUUlVFKQ&marshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp3cmFwKG9iamVjdCk&unmarshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp1bndyYXAob2JqZWN0KQ&convert=©=&repository=|local|vector|||252.904|| +olm_bulk_density_files|stem|30347e1d05fbaf07|bca31cfa4e9e9bb9|ef46db3751d8e999|-839583849||t19836.1958437223s|8c237f5c678b0a48|160|qs|local|vector||olm_bulk_density_files_bdf1cf9b*olm_bulk_density_files_80239220*olm_bulk_density_files_7ede7e84*olm_bulk_density_files_c1215b70*olm_bulk_density_files_a9dbb6f3*olm_bulk_density_files_c5a65b83|0.549|| +olm_bulk_density_rast|stem||073e62d9677edc50|151cab4cc8099d37|420384724||t19836.6224183292s||0|qs|local|vector|||0.006||could not load dependencies of target olm_bulk_density_rast. olm_bulk_density_ce5f99ab must be a vector, not a SpatRaster object. +olm_clay_crop|stem|b07412525d14b1f8|dbdb3f08cae1c67d|3f2f1be1f173ae3c|-822977529||t19836.6519882853s|fc3a74e2606561b8|668056912|format_custom&read=ZnVuY3Rpb24gKHBhdGgpIAp0ZXJyYTo6cmFzdChwYXRoKQ&write=ZnVuY3Rpb24gKG9iamVjdCwgcGF0aCkgCnRlcnJhOjp3cml0ZVJhc3Rlcih4ID0gb2JqZWN0LCBmaWxlbmFtZSA9IHBhdGgsIGZpbGV0eXBlID0gIkdUaWZmIiwgCiAgICBvdmVyd3JpdGUgPSBUUlVFKQ&marshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp3cmFwKG9iamVjdCk&unmarshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp1bndyYXAob2JqZWN0KQ&convert=©=&repository=|local|vector|||234.8|| +olm_clay_files|stem|2b0e4aa4444a65bf|401a586061cb21e4|ef46db3751d8e999|-2095671650||t19836.6479990277s|c303d0aa7a9c897f|156|qs|local|vector|||2.881|| +olm_combined|stem|969c76e03fbe52c2|2f4fd18543e2b544|bfabc122cf886d45|-177036321||t19836.865384886s||694094|qs|local|vector|||||_build_ target olm_combined did not return a character. dynamic files targets with format file must return character vectors of file or directory paths. +olm_oc_crop|stem|3e3dfe9bd27c190d|286bdfd32a8ccc56|e8db6041a9d6f9ff|-390664998||t19836.6507074066s|02919f660f138b58|472443129|format_custom&read=ZnVuY3Rpb24gKHBhdGgpIAp0ZXJyYTo6cmFzdChwYXRoKQ&write=ZnVuY3Rpb24gKG9iamVjdCwgcGF0aCkgCnRlcnJhOjp3cml0ZVJhc3Rlcih4ID0gb2JqZWN0LCBmaWxlbmFtZSA9IHBhdGgsIGZpbGV0eXBlID0gIkdUaWZmIiwgCiAgICBvdmVyd3JpdGUgPSBUUlVFKQ&marshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp3cmFwKG9iamVjdCk&unmarshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp1bndyYXAob2JqZWN0KQ&convert=©=&repository=|local|vector|||178.614|| +olm_oc_files|stem|cbb6bf888139d5bc|7941d2cda87c49c2|ef46db3751d8e999|-723769669||t19836.6479936437s|e209d753280b6d62|157|qs|local|vector|||2.996|| +olm_pH_crop|stem|52dda7c1e33c4cf7|688aa9c1fb921441|e3f91e85b380c2af|-562540966||t19836.6511272402s|665d66a15efe825b|547849510|format_custom&read=ZnVuY3Rpb24gKHBhdGgpIAp0ZXJyYTo6cmFzdChwYXRoKQ&write=ZnVuY3Rpb24gKG9iamVjdCwgcGF0aCkgCnRlcnJhOjp3cml0ZVJhc3Rlcih4ID0gb2JqZWN0LCBmaWxlbmFtZSA9IHBhdGgsIGZpbGV0eXBlID0gIkdUaWZmIiwgCiAgICBvdmVyd3JpdGUgPSBUUlVFKQ&marshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp3cmFwKG9iamVjdCk&unmarshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp1bndyYXAob2JqZWN0KQ&convert=©=&repository=|local|vector|||230.365|| +olm_pH_files|stem|6194a39b0bfadd2c|917c99e5ee1912da|ef46db3751d8e999|-749722079||t19836.6479935094s|6935d04907feb3d2|146|qs|local|vector|||2.997|| +olm_read_crop|function|f7d7c25dbcb60964||||||||||||||| +olm_sand_crop|stem|5b924bfcb4e1c056|efd243064da48478|cebcf145a9615344|-1024084429||t19836.6527542258s|898d0f63375b70a8|751445614|format_custom&read=ZnVuY3Rpb24gKHBhdGgpIAp0ZXJyYTo6cmFzdChwYXRoKQ&write=ZnVuY3Rpb24gKG9iamVjdCwgcGF0aCkgCnRlcnJhOjp3cml0ZVJhc3Rlcih4ID0gb2JqZWN0LCBmaWxlbmFtZSA9IHBhdGgsIGZpbGV0eXBlID0gIkdUaWZmIiwgCiAgICBvdmVyd3JpdGUgPSBUUlVFKQ&marshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp3cmFwKG9iamVjdCk&unmarshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp1bndyYXAob2JqZWN0KQ&convert=©=&repository=|local|vector|||376.952|| +olm_sand_files|stem|2b7b7376b5dd00c4|3e26407b0f28f2d6|ef46db3751d8e999|-2105413905||t19836.647998331s|2f4c0f199b39241a|151|qs|local|vector|||2.861|| +olm_soil_order_crop|stem|32a6aed0171ec3cf|7e5560ba7c4f0adf|5a6f2dca986df885|518183517||t19836.7983401002s|f2302fddbf3c9acf|1359790276|format_custom&read=ZnVuY3Rpb24gKHBhdGgpIAp0ZXJyYTo6cmFzdChwYXRoKQ&write=ZnVuY3Rpb24gKG9iamVjdCwgcGF0aCkgCnRlcnJhOjp3cml0ZVJhc3Rlcih4ID0gb2JqZWN0LCBmaWxlbmFtZSA9IHBhdGgsIGZpbGV0eXBlID0gIkdUaWZmIiwgCiAgICBvdmVyd3JpdGUgPSBUUlVFKQ&marshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp3cmFwKG9iamVjdCk&unmarshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp1bndyYXAob2JqZWN0KQ&convert=©=&repository=|local|vector|||100.606|| +olm_soil_order_files|stem|2b300ff243109afc|d4b05ea62a379f15|ef46db3751d8e999|602322045||t19836.796339452s|0e833cdd3158622c|249|qs|local|vector|||2.973|| +olm_texture_crop|stem|5f7f1dbd050f49a9|9059ab6dc052325f|899d154c23a2a949|913275893||t19836.7973006947s|640565de3a140213|156772208|format_custom&read=ZnVuY3Rpb24gKHBhdGgpIAp0ZXJyYTo6cmFzdChwYXRoKQ&write=ZnVuY3Rpb24gKG9iamVjdCwgcGF0aCkgCnRlcnJhOjp3cml0ZVJhc3Rlcih4ID0gb2JqZWN0LCBmaWxlbmFtZSA9IHBhdGgsIGZpbGV0eXBlID0gIkdUaWZmIiwgCiAgICBvdmVyd3JpdGUgPSBUUlVFKQ&marshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp3cmFwKG9iamVjdCk&unmarshal=ZnVuY3Rpb24gKG9iamVjdCkgCnRlcnJhOjp1bndyYXAob2JqZWN0KQ&convert=©=&repository=|local|vector|||54.824|| +olm_texture_files|stem|441aa32f47d95f65|ca0eb0d78942bed1|ef46db3751d8e999|99093571||t19836.7963395375s|97f5d5ebb4412369|161|qs|local|vector|||2.976|| partition_data|stem||7a0c055c8a17fa7c|3d381271a41ec1da|1876425578||t19808.1080950632s||0|qs|local|vector|||0.056||Cant subset columns that dont exist.31m39m Column rewferenceg doesnt exist. partition_datasets|function|6c216a0d6f2c2064||||||||||||||| -pesticide_censored|stem|b9753469aaed4219|3f424cf6d1bab7ee|694e97123599a181|-2112144838||t19832.786724537s|a9b37443c671d4ff|1283779|qs|local|vector|||0.209|| -pesticide_daily|stem|78a9c940086f6285|35b0dce340c44199|f9ef2bda74a1a42f|-230510056||t19832.7905208333s|f1acac7f8a7f9500|1337810|qs|local|vector|||8.375|| -pesticide_yearly|stem|d4b299de55fd4002|ecb6947a11e9c859|1f89873eb4aea48a|8288270||t19832.7928472222s|bf7da7a647b7e93d|1312371|qs|local|vector|||3.526|| -pesticide_yearly_filtered|stem|f8e06175c8b2dfd1|8ae33bf864d5489c|92960b35e1d3690f|642415236||t19832.8100925926s|b6c8565cd9656aae|1326078|qs|local|vector|||0.286|| +pesticide_censored|stem|b9753469aaed4219|3f424cf6d1bab7ee|694e97123599a181|-2112144838||t19836.0983088872s|a9b37443c671d4ff|1283779|qs|local|vector|||0.061|| +pesticide_daily|stem|78a9c940086f6285|35b0dce340c44199|f9ef2bda74a1a42f|-230510056||t19836.0984101843s|f1acac7f8a7f9500|1337810|qs|local|vector|||8.366|| +pesticide_yearly|stem|d4b299de55fd4002|ecb6947a11e9c859|1f89873eb4aea48a|8288270||t19836.0984514389s|bf7da7a647b7e93d|1312371|qs|local|vector|||3.205|| +pesticide_yearly_filtered|stem|f8e06175c8b2dfd1|8ae33bf864d5489c|92960b35e1d3690f|642415236||t19836.0984568589s|b6c8565cd9656aae|1326078|qs|local|vector|||0.109|| pivot_covariates|function|6664f2b8836c0d3a||||||||||||||| plot_by_kfold|pattern|a30073943496f479|86a50e5d0be82ec1||-304556969||||3909188|qs|local|list||plot_by_kfold_1399cb75*plot_by_kfold_ff85d877*plot_by_kfold_1ebb2130*plot_by_kfold_4fc0f128*plot_by_kfold_3700628a*plot_by_kfold_33f4b968*plot_by_kfold_01e8eaf6*plot_by_kfold_937ac923*plot_by_kfold_531e893d*plot_by_kfold_1b9b4600|0.038|| plot_by_kfold_01e8eaf6|branch|e80bc1cb6dfabc24|86a50e5d0be82ec1|cbf564a34a9bbb4e|-2100683564||t19810.6692615843s|06cf0f6815b06fdb|285217|qs|local|list|plot_by_kfold||0.003|| @@ -223,75 +243,96 @@ sf_covariates_pivot|stem|3fdeffa41263978d|f8393f57856d9d0d|27dfc9d6d369190f|2081 sf_explore_cov_maps|stem|c1b327b4d2e7940d|f2febdc63f773962|ef9bf7a5399b7981|1230089317||t19810.6691657555s|c05d96450ab04dba|1293063|qs|local|group||sf_explore_cov_maps_4bca4dbb*sf_explore_cov_maps_9a0ec978*sf_explore_cov_maps_6938bf22*sf_explore_cov_maps_b924afcd*sf_explore_cov_maps_3eea8019*sf_explore_cov_maps_3b433a1f*sf_explore_cov_maps_0990be6e*sf_explore_cov_maps_dd5dad3e*sf_explore_cov_maps_8a5b3ba7*sf_explore_cov_maps_18810db2*sf_explore_cov_maps_fce897cd*sf_explore_cov_maps_504b41a4*sf_explore_cov_maps_922fc483*sf_explore_cov_maps_4bf4209f*sf_explore_cov_maps_9a2da990|0.034|| sf_explore_outcome_maps|stem|cca1ade374ca9cfe|49a633014dfb8e35|3b0a6394321c1562|701109624||t19809.8678887653s|8f3bd4c7c13ff63d|502957|qs|local|group||sf_explore_outcome_maps_37ece6c5*sf_explore_outcome_maps_cefc303e*sf_explore_outcome_maps_d535bb4c*sf_explore_outcome_maps_947a572f*sf_explore_outcome_maps_e639568d*sf_explore_outcome_maps_4d8972e1|0.012|| sf_lasso_mvn|stem|0c42219cbe17b51d|ec6473002bc92b62|93838922beec9c58|1652653611||t19810.7198813779s||83865917|qs|local|group||sf_lasso_mvn_21eb2e34*sf_lasso_mvn_1f5130bf*sf_lasso_mvn_ea2f04f0*sf_lasso_mvn_f7b601ff*sf_lasso_mvn_b3b770b7*sf_lasso_mvn_32f30d04*sf_lasso_mvn_6437d09d*sf_lasso_mvn_97df0c82*sf_lasso_mvn_6ac9bd5f*sf_lasso_mvn_21eb677b|0.014||tar_group_by columns must be in data. -sf_pesticide|stem|3df2f0f51cfc185a|bfb542d0cf5816fc|9d4d028d54eb2f62|-749829516||t19832.8101041667s|ae83af9f971b5f08|1063856|qs|local|vector|||0.054|| +sf_pesticide|stem|7f5979d4cbecea07|10416a46833e0d57|9d4d028d54eb2f62|-749829516||t19836.168722045s|95dbb116c1f17a0d|1063278|qs|local|vector|||0.104|| sf_pesticide_cv|stem|c4b03d5a1f97084e|4f38ef817bca02cd|808826f750e5d8f2|1101330710||t19807.6510946537s|e213995900e489b8|86235130|qs|local|vector|||0.003|| sf_pesticide_cv_group|stem|db783f697180468d|4ae824ffc75591a0|3c1fddcc98b7a472|-72964414||t19810.6692386993s|c523ed38fa0c54c0|514347|qs|local|group||sf_pesticide_cv_group_b1039516*sf_pesticide_cv_group_337b05f4*sf_pesticide_cv_group_30588b4e*sf_pesticide_cv_group_5a8bb068*sf_pesticide_cv_group_e14584c2*sf_pesticide_cv_group_b3dfdd2b*sf_pesticide_cv_group_03c0daf2*sf_pesticide_cv_group_e0364fa0*sf_pesticide_cv_group_62a5de3a*sf_pesticide_cv_group_7d3d3d80|0.005|| sf_pesticide_dummies_cv|stem|893811a92b39e07c|7a937d7e44907e33|8543d0d147800125|1153720038||t19810.6692001703s|264504698c717ee5|86972179|qs|local|vector|||0.006|| sf_pesticide_filtered_cleaned|stem||f56a97d457015fa8|dad3d6b19f01ab02|-930242163||t19808.5918488583s||0|qs|local|vector|||0.026||1m22mselect doesnt handle lists. sf_pesticide_for_fit|stem|efe40f79adeffe37|073ae76c111f91cc|b8e4efbf94565066|-1495200753||t19828.1272173687s|ebf21ef82fa6f3c4|2228585|qs|local|vector|||0.066|| -sf_pesticide_huc|stem|f038bad6a4ff1d10|4babb667eb7d7c5c|a27314b4d21b2a17|-1615822091||t19832.8682175926s|589c5c83dd5adcb2|771310|qs|local|vector|||153.521|GDAL Message 1 organizePolygons received a polygon with more than 100 parts. The processing may be really slow. You can skip the processing by setting METHODSKIP.| -sf_pesticide_partition|stem|17a32da1f91f7865|7a0c055c8a17fa7c|12786b53912a92a7|-713680612||t19828.1233588359s|d68fb2b4e9ad8c35|86599411|qs|local|vector|||0.029|| -sf_pesticide_partition_cleaned|stem|637a234a98d26bb1|d87c1f0055f0c409|76ea73353ee5d208|1820727072||t19828.8177733363s|d21a6867e6dadaf7|86641961|qs|local|vector|||4.282|1m22mfct_explicit_na was deprecated in forcats 1.0.0.36mℹ39m Please use fct_na_value_to_level instead.| +sf_pesticide_huc|stem|31b83fb3dfac937f|6f253304aaa9c3db|859079eebdc242f4|-1615822091||t19836.1692750655s|6b706f113e7eecc5|2470764|qs|local|vector|||47.684|GDAL Message 1 organizePolygons received a polygon with more than 100 parts. The processing may be really slow. You can skip the processing by setting METHODSKIP.| +sf_pesticide_partition|stem|17a32da1f91f7865|7a0c055c8a17fa7c|271b8287fb47e8e9|-713680612||t19828.1233588359s||2.2250738585072e-308|qs|local|vector|||0.048||Cant select columns that dont exist.31m39m Column ChmclNm doesnt exist. +sf_pesticide_partition_cleaned|stem|637a234a98d26bb1|d87c1f0055f0c409|453f226c45198af5|1820727072||t19828.8177733363s||86641961|qs|local|vector|||0.162||object sf_pesticide_partition not found sf_plot_outcome_maps|stem|2387ab545ecb7c1c|49a633014dfb8e35|72365e51e29ffb76|-1913193101||t19828.8179881257s|6d94e3d42855fd55|84245045|qs|local|group||sf_plot_outcome_maps_17fe1b3d*sf_plot_outcome_maps_58c02e22*sf_plot_outcome_maps_4b2a7e31*sf_plot_outcome_maps_59ee3f8f*sf_plot_outcome_maps_8e00bf55*sf_plot_outcome_maps_76c0b6cd|0.014|| spatial_kfold|stem|110fc74925afdd94|d7317d9f2af2d7c8|72365e51e29ffb76|1194645416||t19828.8179596531s|0ff9d3c7d2563457|842768350|qs|local|vector|||2.563|| spatial_kfold_split_be2f3a11|branch||673ef836758d5e8e|ef46db3751d8e999|-1460010595||t19828.7358861258s||0|qs|local|vector|spatial_kfold_split||0.014||No get_rsplit method for this classes tbl_df, tbl, data.frame spatial_splits|stem|c294abd20d9305db|4f73b0a72aa40ca1|c630db5a19f0acab|-2000834859||t19828.6741747295s|5579a80a3dde5ee5|843518614|qs|local|group||spatial_splits_8983e186*spatial_splits_d9673ba5*spatial_splits_760723db*spatial_splits_6617eeec*spatial_splits_fd9b77fe*spatial_splits_ecd635cf*spatial_splits_3831847f*spatial_splits_b7390ddc*spatial_splits_9a680775*spatial_splits_3f9b25fd|5.035|| state_fun_AZO|function|cc0ee1a0aed422c7||||||||||||||| -state_list|stem|71951d5ec20eb13a|c47910f614d588d9|ef46db3751d8e999|520344596||t19832.7744560185s|094cdf8ee71e1e88|135|qs|local|vector||state_list_f22cbb07*state_list_d3e84034*state_list_71dbaf9f*state_list_1c68a427*state_list_b938fc8e*state_list_addba94f*state_list_14e6a3f8*state_list_0a22c92e*state_list_73be5dbd*state_list_f225899a*state_list_bb127368*state_list_be861ba9*state_list_5327023e*state_list_2f1e9252*state_list_b697ab7d*state_list_648b4517*state_list_25c130d2*state_list_6d78c037*state_list_167fc184*state_list_4ff364cc*state_list_53d1ed5c*state_list_57961301*state_list_1cb6d315*state_list_94326d25*state_list_6f8df5b7*state_list_e0e70a2b*state_list_5728d8a2*state_list_fffd4809*state_list_bd119316*state_list_581e4992*state_list_e3535664*state_list_df5b60c4*state_list_2bcba3ef*state_list_8339d7c0*state_list_a640f613*state_list_1db0d8e8*state_list_ce340191*state_list_1cdb089d*state_list_6a3d418d*state_list_41a959c8*state_list_6d5f03a3*state_list_a05b5392*state_list_011f89c8*state_list_13111247*state_list_a0a95fe2*state_list_558a2426*state_list_2b4de976*state_list_580a091a|0.001|| -state_pesticide|pattern|de4b44cf1cc58ab7|49679374232582c0||-114876071||||3495280|qs|local|vector||state_pesticide_1131df76*state_pesticide_71e58d22*state_pesticide_29966f1d*state_pesticide_bfe72e55*state_pesticide_7a46c38b*state_pesticide_4500bf15*state_pesticide_7d6ceee4*state_pesticide_567fb042*state_pesticide_e4130b01*state_pesticide_0b2ffdbc*state_pesticide_37d878ec*state_pesticide_64422a95*state_pesticide_33835831*state_pesticide_b3298e34*state_pesticide_cc3b828c*state_pesticide_baa73d14*state_pesticide_03945d73*state_pesticide_79038223*state_pesticide_8dfcc088*state_pesticide_e4c3e020*state_pesticide_18963d7f*state_pesticide_fa5f609e*state_pesticide_8622c393*state_pesticide_aa680b60*state_pesticide_fd520386*state_pesticide_b1557609*state_pesticide_24e28b0e*state_pesticide_c988cda9*state_pesticide_47b1f0d8*state_pesticide_6ce189bd*state_pesticide_bfc1f1c7*state_pesticide_5464a00a*state_pesticide_2837f42d*state_pesticide_3cb35e14*state_pesticide_9ff905dc*state_pesticide_b55cc252*state_pesticide_2a2952d3*state_pesticide_18444282*state_pesticide_4017b75a*state_pesticide_49aa2d88*state_pesticide_468fc9a0*state_pesticide_79d32c3e*state_pesticide_09d3e928*state_pesticide_d3af20cb*state_pesticide_0eb4d48b*state_pesticide_be78befd*state_pesticide_62acfe29*state_pesticide_daf72072|154.229|| -state_pesticide_03945d73|branch|50a32e0a9aea61fd|49679374232582c0|14cd87614565fa4d|1267456546||t19832.7753009259s|eb9ad0e242bb7055|15749|qs|local|vector|state_pesticide||1.493|| -state_pesticide_09d3e928|branch|e89e87e75e31bb83|49679374232582c0|14cd87614565fa4d|1788656146||t19832.7761458333s|4263419c1b81ec76|4700|qs|local|vector|state_pesticide||1.268|| -state_pesticide_0b2ffdbc|branch|28d41525b9bb21d1|49679374232582c0|14cd87614565fa4d|-1007947837||t19832.7750578704s|0b7d6ec5cd36c969|52074|qs|local|vector|state_pesticide||3.712|| -state_pesticide_0eb4d48b|branch|823410e3750c659a|49679374232582c0|14cd87614565fa4d|1896271325||t19832.7762152778s|a053a17e12a49992|57906|qs|local|vector|state_pesticide||3.104|| -state_pesticide_1131df76|branch|41d4b5664f1a11df|49679374232582c0|14cd87614565fa4d|-744121290||t19832.7745138889s|af5fa8a0bb50108e|52991|qs|local|vector|state_pesticide||4.327|| -state_pesticide_18444282|branch|03d0f5574e6eec43|49679374232582c0|14cd87614565fa4d|-772965900||t19832.7760069444s|3cf5d21fb1473355|37653|qs|local|vector|state_pesticide||2.077|| -state_pesticide_18963d7f|branch|bc1638a5327d4472|49679374232582c0|14cd87614565fa4d|-734688568||t19832.7754398148s|c72cb0e7d7a23f5a|152289|qs|local|vector|state_pesticide||4.48|1m22mDetected an unexpected manytomany relationship between x and y.36mℹ39m Row 2940 of x matches multiple rows in y.36mℹ39m Row 25 of y matches multiple rows in x.36mℹ39m If a manytomany relationship is expected, set relationship manytomany to silence this warning.| -state_pesticide_24e28b0e|branch|19fd7b38484e879a|49679374232582c0|14cd87614565fa4d|-1812110026||t19832.775625s|5b0b8c93a2432af6|14412|qs|local|vector|state_pesticide||1.435|| -state_pesticide_2837f42d|branch|902cb958cf4bce10|49679374232582c0|14cd87614565fa4d|-320952067||t19832.7758680556s|5db3b595b84517c7|39341|qs|local|vector|state_pesticide||2.277|| -state_pesticide_29966f1d|branch|0dcb3ee558e2921b|49679374232582c0|14cd87614565fa4d|1167094295||t19832.7745601852s|a01e8714d2f18741|20448|qs|local|vector|state_pesticide||2.219|| -state_pesticide_2a2952d3|branch|da08bb061ae6a4ad|49679374232582c0|14cd87614565fa4d|-1041595939||t19832.7759837963s|5098993db9a02026|6187|qs|local|vector|state_pesticide||1.41|| -state_pesticide_33835831|branch|f2bae6d7f105c54f|49679374232582c0|14cd87614565fa4d|1324022479||t19832.7751851852s|5f78e8a909e650fe|149092|qs|local|vector|state_pesticide||4.859|| -state_pesticide_37d878ec|branch|eb5509b174a32475|49679374232582c0|14cd87614565fa4d|893036782||t19832.7751041667s|77bbf6e1ea01f6bc|73654|qs|local|vector|state_pesticide||3.265|| -state_pesticide_3cb35e14|branch|6e8504dd23044169|49679374232582c0|14cd87614565fa4d|1589157540||t19832.7758912037s|42551f8b5b40a126|18641|qs|local|vector|state_pesticide||1.715|| -state_pesticide_4017b75a|branch|b430c1208f37d08e|49679374232582c0|14cd87614565fa4d|344182858||t19832.7760185185s|d297c99ad21ab631|4782|qs|local|vector|state_pesticide||1.325|| -state_pesticide_4500bf15|branch|2b7c773be91ef795|49679374232582c0|14cd87614565fa4d|-1152300280||t19832.7749189815s|da04bff30f284996|28097|qs|local|vector|state_pesticide||2.156|| -state_pesticide_468fc9a0|branch|0bb1ebfa125db4ec|49679374232582c0|14cd87614565fa4d|551422361||t19832.7761111111s|60e45afa6c75cb75|179255|qs|local|vector|state_pesticide||5.143|1m22mDetected an unexpected manytomany relationship between x and y.36mℹ39m Row 3206 of x matches multiple rows in y.36mℹ39m Row 527 of y matches multiple rows in x.36mℹ39m If a manytomany relationship is expected, set relationship manytomany to silence this warning.| -state_pesticide_47b1f0d8|branch|78953f3e36ac6d07|49679374232582c0|14cd87614565fa4d|53329600||t19832.7757060185s|d6c82007d6a1809e|42348|qs|local|vector|state_pesticide||2.236|| -state_pesticide_49aa2d88|branch|36d087f7ad1049b6|49679374232582c0|14cd87614565fa4d|-968698370||t19832.7760416667s|26ae6a80073b65d9|37900|qs|local|vector|state_pesticide||2.064|| -state_pesticide_5464a00a|branch|558278ccb783e3f5|49679374232582c0|14cd87614565fa4d|-515681427||t19832.7758449074s|2e49824cbb4ffd46|11560|qs|local|vector|state_pesticide||1.638|| -state_pesticide_567fb042|branch|c837d63041aab1ef|49679374232582c0|14cd87614565fa4d|973186787||t19832.7749768519s|69093a086c0811a1|76443|qs|local|vector|state_pesticide||3.232|| -state_pesticide_62acfe29|branch|78e5807415159373|49679374232582c0|14cd87614565fa4d|397762833||t19832.7762615741s|7ab3753b8850e217|43234|qs|local|vector|state_pesticide||2.713|| -state_pesticide_64422a95|branch|0311ebac65e68a5f|49679374232582c0|14cd87614565fa4d|1182666852||t19832.7751273148s|f71c623f389903f2|36102|qs|local|vector|state_pesticide||2.456|| -state_pesticide_6ce189bd|branch|0b7584da7b9cadee|49679374232582c0|14cd87614565fa4d|1037247512||t19832.775787037s|3927e442ea9db270|297848|qs|local|vector|state_pesticide||7.404|| -state_pesticide_71e58d22|branch|828d48b2a8e7c3cb|49679374232582c0|14cd87614565fa4d|-1137423069||t19832.774537037s|e031d2c6d71292b2|19352|qs|local|vector|state_pesticide||2.087|| -state_pesticide_79038223|branch|d559c3dbb6cef6bc|49679374232582c0|14cd87614565fa4d|-923057110||t19832.7753356481s|801742fcc2eb455a|82394|qs|local|vector|state_pesticide||3.145|| -state_pesticide_79d32c3e|branch|78119fb3b0e922c6|49679374232582c0|14cd87614565fa4d|-293175114||t19832.7761342593s|202453ce10c2cec2|45632|qs|local|vector|state_pesticide||2.305|| -state_pesticide_7a46c38b|branch|8150e7cd53a722bb|49679374232582c0|14cd87614565fa4d|-919821490||t19832.7748958333s|ddf4b5f9ab9f452f|59165|qs|local|vector|state_pesticide||3.595|| -state_pesticide_7d6ceee4|branch|777cf2d34939b514|49679374232582c0|14cd87614565fa4d|721551165||t19832.7749421296s|b4824669223a109b|29578|qs|local|vector|state_pesticide||1.917|| -state_pesticide_8622c393|branch|19d171a43715c6aa|49679374232582c0|14cd87614565fa4d|-520957089||t19832.7754976852s|7c034c433e476758|32868|qs|local|vector|state_pesticide||3.006|| -state_pesticide_8dfcc088|branch|524aede24353a91e|49679374232582c0|14cd87614565fa4d|-1720445271||t19832.7753587963s|b5b886ef5122ba25|30933|qs|local|vector|state_pesticide||1.854|| -state_pesticide_9ff905dc|branch|0006b94999f027c4|49679374232582c0|14cd87614565fa4d|1672283516||t19832.7759143519s|7d27509c31de42fa|11817|qs|local|vector|state_pesticide||2.387|| -state_pesticide_aa680b60|branch|c91df379bb128b7a|49679374232582c0|14cd87614565fa4d|-1551046146||t19832.7755208333s|b00a17eaf956b637|17466|qs|local|vector|state_pesticide||1.733|| -state_pesticide_b1557609|branch|fcbe399e14a8b23a|49679374232582c0|14cd87614565fa4d|-1934674019||t19832.7756018519s|bbc1fd76222b4554|53331|qs|local|vector|state_pesticide||2.708|| -state_pesticide_b3298e34|branch|89daea669ee5d617|49679374232582c0|14cd87614565fa4d|-1170343882||t19832.7752430556s|f75c5d929a8dcb23|203898|qs|local|vector|state_pesticide||4.583|| -state_pesticide_b55cc252|branch|053ccf780fcd751f|49679374232582c0|14cd87614565fa4d|53519870||t19832.7759606481s|b5b57dde0e02a295|88952|qs|local|vector|state_pesticide||3.546|| -state_pesticide_baa73d14|branch|af45d89dbdac89e2|49679374232582c0|14cd87614565fa4d|-1425466781||t19832.7752777778s|a8fa57edd68032bd|56971|qs|local|vector|state_pesticide||2.769|| -state_pesticide_be78befd|branch|7dfaed4a3eb157b6|49679374232582c0|14cd87614565fa4d|732950819||t19832.7762384259s|550c765c6a0c03f2|17860|qs|local|vector|state_pesticide||1.543|| -state_pesticide_bfc1f1c7|branch|7b3bc0de92f30172|49679374232582c0|14cd87614565fa4d|-586376084||t19832.7758217593s|370392aa2c305156|37897|qs|local|vector|state_pesticide||2.315|| -state_pesticide_bfe72e55|branch|4794c329b7f6635b|49679374232582c0|14cd87614565fa4d|-342488832||t19832.774849537s|4392c8b8ad3cbe06|769075|qs|local|vector|state_pesticide||24.848|| -state_pesticide_c988cda9|branch|3aa7993219ca9e6e|49679374232582c0|14cd87614565fa4d|-254112269||t19832.7756712963s|fe82b96cf3d63492|166428|qs|local|vector|state_pesticide||4.539|| -state_pesticide_cc3b828c|branch|6dd71d12008128c1|49679374232582c0|14cd87614565fa4d|745296327||t19832.7752430556s|de1c6d017cb4e8a8|38|qs|local|vector|state_pesticide||0.466|| -state_pesticide_combined|stem|674c15c22de489b2|ecbaceb6dd1acf4e|d6381f329234b02f|-248763802||t19832.7861921296s|86e4b55d9c0e3fd8|2526315|qs|local|vector|||0.008|| -state_pesticide_d3af20cb|branch|cad66c53a9e34367|49679374232582c0|14cd87614565fa4d|-934136572||t19832.7761805556s|9584b18e44c7252a|28989|qs|local|vector|state_pesticide||2.354|| -state_pesticide_daf72072|branch|6851a390bdc31bd2|49679374232582c0|14cd87614565fa4d|-825099448||t19832.7763078704s|06fa4e60d33fffce|86758|qs|local|vector|state_pesticide||3.123|| -state_pesticide_e4130b01|branch|1b8b504411c600a0|49679374232582c0|14cd87614565fa4d|-67432851||t19832.7750115741s|138d0f75ab050110|46120|qs|local|vector|state_pesticide||2.819|| -state_pesticide_e4c3e020|branch|a847c5eeeddeedb2|49679374232582c0|14cd87614565fa4d|979591373||t19832.7753819444s|93b7a2facf0d92b9|29348|qs|local|vector|state_pesticide||2.101|| -state_pesticide_fa5f609e|branch|9726dcf9ac749945|49679374232582c0|14cd87614565fa4d|-180838893||t19832.775462963s|d014524ea30b0a92|16713|qs|local|vector|state_pesticide||1.692|| -state_pesticide_fd520386|branch|3fc8c0f065b2a364|49679374232582c0|14cd87614565fa4d|2126256019||t19832.7755671296s|bce3e3c62c071dfb|110991|qs|local|vector|state_pesticide||4.786|| +state_list|stem|71951d5ec20eb13a|c47910f614d588d9|ef46db3751d8e999|520344596||t19836.0964607508s|094cdf8ee71e1e88|135|qs|local|vector||state_list_f22cbb07*state_list_d3e84034*state_list_71dbaf9f*state_list_1c68a427*state_list_b938fc8e*state_list_addba94f*state_list_14e6a3f8*state_list_0a22c92e*state_list_73be5dbd*state_list_f225899a*state_list_bb127368*state_list_be861ba9*state_list_5327023e*state_list_2f1e9252*state_list_b697ab7d*state_list_648b4517*state_list_25c130d2*state_list_6d78c037*state_list_167fc184*state_list_4ff364cc*state_list_53d1ed5c*state_list_57961301*state_list_1cb6d315*state_list_94326d25*state_list_6f8df5b7*state_list_e0e70a2b*state_list_5728d8a2*state_list_fffd4809*state_list_bd119316*state_list_581e4992*state_list_e3535664*state_list_df5b60c4*state_list_2bcba3ef*state_list_8339d7c0*state_list_a640f613*state_list_1db0d8e8*state_list_ce340191*state_list_1cdb089d*state_list_6a3d418d*state_list_41a959c8*state_list_6d5f03a3*state_list_a05b5392*state_list_011f89c8*state_list_13111247*state_list_a0a95fe2*state_list_558a2426*state_list_2b4de976*state_list_580a091a|2.844|| +state_pesticide|pattern|8595381893ccf8a0|49679374232582c0||-114876071||||3495328|qs|local|vector||state_pesticide_1131df76*state_pesticide_71e58d22*state_pesticide_29966f1d*state_pesticide_bfe72e55*state_pesticide_7a46c38b*state_pesticide_4500bf15*state_pesticide_7d6ceee4*state_pesticide_567fb042*state_pesticide_e4130b01*state_pesticide_0b2ffdbc*state_pesticide_37d878ec*state_pesticide_64422a95*state_pesticide_33835831*state_pesticide_b3298e34*state_pesticide_cc3b828c*state_pesticide_baa73d14*state_pesticide_03945d73*state_pesticide_79038223*state_pesticide_8dfcc088*state_pesticide_e4c3e020*state_pesticide_18963d7f*state_pesticide_fa5f609e*state_pesticide_8622c393*state_pesticide_aa680b60*state_pesticide_fd520386*state_pesticide_b1557609*state_pesticide_24e28b0e*state_pesticide_c988cda9*state_pesticide_47b1f0d8*state_pesticide_6ce189bd*state_pesticide_bfc1f1c7*state_pesticide_5464a00a*state_pesticide_2837f42d*state_pesticide_3cb35e14*state_pesticide_9ff905dc*state_pesticide_b55cc252*state_pesticide_2a2952d3*state_pesticide_18444282*state_pesticide_4017b75a*state_pesticide_49aa2d88*state_pesticide_468fc9a0*state_pesticide_79d32c3e*state_pesticide_09d3e928*state_pesticide_d3af20cb*state_pesticide_0eb4d48b*state_pesticide_be78befd*state_pesticide_62acfe29*state_pesticide_daf72072|294.907|| +state_pesticide_03945d73|branch|cab51d4b3835e8a6|49679374232582c0|14cd87614565fa4d|1267456546||t19836.0977347133s|36ea4727e7e31258|15748|qs|local|vector|state_pesticide||2.63|| +state_pesticide_09d3e928|branch|3a3856bbae06272d|49679374232582c0|14cd87614565fa4d|1788656146||t19836.0981301428s|8a01085e4d879477|4702|qs|local|vector|state_pesticide||1.626|| +state_pesticide_0b2ffdbc|branch|d6811ee36af4cf1a|49679374232582c0|14cd87614565fa4d|-1007947837||t19836.0976009896s|0b7d6ec5cd36c969|52074|qs|local|vector|state_pesticide||7.162|| +state_pesticide_0eb4d48b|branch|2338c42cc27756f4|49679374232582c0|14cd87614565fa4d|1896271325||t19836.0982149472s|fec03177be1cbb38|57908|qs|local|vector|state_pesticide||7.299|| +state_pesticide_1131df76|branch|9e22eb36edb87aa7|49679374232582c0|14cd87614565fa4d|-744121290||t19836.097463793s|7c707f0d318ca9ce|52993|qs|local|vector|state_pesticide||8.929|| +state_pesticide_18444282|branch|8f8740c6a50581ec|49679374232582c0|14cd87614565fa4d|-772965900||t19836.0980981054s|dada1264633c4da7|37655|qs|local|vector|state_pesticide||3.752|| +state_pesticide_18963d7f|branch|1d1e5f362697c091|49679374232582c0|14cd87614565fa4d|-734688568||t19836.0979048814s|c72cb0e7d7a23f5a|152289|qs|local|vector|state_pesticide||11.517|Detected an unexpected manytomany relationship between x and y.ℹ Row 2940 of x matches multiple rows in y.ℹ Row 25 of y matches multiple rows in x.ℹ If a manytomany relationship is expected, set relationship manytomany to silence this warning.| +state_pesticide_24e28b0e|branch|9c28aa02ed4b925a|49679374232582c0|14cd87614565fa4d|-1812110026||t19836.097914592s|e2b9758c0fccfde0|14414|qs|local|vector|state_pesticide||2.23|| +state_pesticide_2837f42d|branch|b9df4b587ca36b00|49679374232582c0|14cd87614565fa4d|-320952067||t19836.0980349504s|08c17772b7c48e31|39344|qs|local|vector|state_pesticide||4.298|| +state_pesticide_29966f1d|branch|bed649ec618a2cfb|49679374232582c0|14cd87614565fa4d|1167094295||t19836.0974521538s|94bc075caaac2bec|20453|qs|local|vector|state_pesticide||7.928|| +state_pesticide_2a2952d3|branch|7bc7cb90046a7227|49679374232582c0|14cd87614565fa4d|-1041595939||t19836.0980527535s|6facb3ebc2e5d01b|6186|qs|local|vector|state_pesticide||1.541|| +state_pesticide_33835831|branch|2828adaabcd965a1|49679374232582c0|14cd87614565fa4d|1324022479||t19836.0977249175s|0ef8b260a8437cce|149093|qs|local|vector|state_pesticide||10.643|| +state_pesticide_37d878ec|branch|fe331231e676dbfe|49679374232582c0|14cd87614565fa4d|893036782||t19836.097621642s|7b29f8941b10432b|73655|qs|local|vector|state_pesticide||5.672|| +state_pesticide_3cb35e14|branch|bcef51cb954be389|49679374232582c0|14cd87614565fa4d|1589157540||t19836.0980300116s|42551f8b5b40a126|18641|qs|local|vector|state_pesticide||2.377|| +state_pesticide_4017b75a|branch|f381b895059cc5fe|49679374232582c0|14cd87614565fa4d|344182858||t19836.0980779326s|0b102b23e1baa41b|4784|qs|local|vector|state_pesticide||1.877|| +state_pesticide_4500bf15|branch|b5bf1966ea7a0345|49679374232582c0|14cd87614565fa4d|-1152300280||t19836.0974929521s|f832ab153283eb2e|28095|qs|local|vector|state_pesticide||3.509|| +state_pesticide_468fc9a0|branch|faaf9dc3710b3fd5|49679374232582c0|14cd87614565fa4d|551422361||t19836.0982165447s|60e45afa6c75cb75|179255|qs|local|vector|state_pesticide||11.9|Detected an unexpected manytomany relationship between x and y.ℹ Row 3206 of x matches multiple rows in y.ℹ Row 527 of y matches multiple rows in x.ℹ If a manytomany relationship is expected, set relationship manytomany to silence this warning.| +state_pesticide_47b1f0d8|branch|f7fc2c4a1a380bbc|49679374232582c0|14cd87614565fa4d|53329600||t19836.0979568134s|d6c82007d6a1809e|42348|qs|local|vector|state_pesticide||3.633|| +state_pesticide_49aa2d88|branch|1dd03ae1ad2ff977|49679374232582c0|14cd87614565fa4d|-968698370||t19836.0981160446s|6b471c705f9271fc|37901|qs|local|vector|state_pesticide||4.097|| +state_pesticide_5464a00a|branch|d0ffe736a17d1a1e|49679374232582c0|14cd87614565fa4d|-515681427||t19836.0979850344s|114843724939d25a|11561|qs|local|vector|state_pesticide||2.431|| +state_pesticide_567fb042|branch|9e0df33cc96a06b1|49679374232582c0|14cd87614565fa4d|973186787||t19836.097555751s|e1cfde88d3ba8914|76446|qs|local|vector|state_pesticide||5.4|| +state_pesticide_62acfe29|branch|15fdb848d982a3c8|49679374232582c0|14cd87614565fa4d|397762833||t19836.0982040137s|56034ae71249f849|43236|qs|local|vector|state_pesticide||4.143|| +state_pesticide_64422a95|branch|5e9f0d88aadfc069|49679374232582c0|14cd87614565fa4d|1182666852||t19836.0976266303s|be0ef045a89b8ef9|36103|qs|local|vector|state_pesticide||5.461|| +state_pesticide_6ce189bd|branch|9b1461b41a976e27|49679374232582c0|14cd87614565fa4d|1037247512||t19836.0980693272s|3927e442ea9db270|297848|qs|local|vector|state_pesticide||12.712|| +state_pesticide_71e58d22|branch|6723866d9d81eed3|49679374232582c0|14cd87614565fa4d|-1137423069||t19836.0974519739s|18081bb3ffaac16d|19355|qs|local|vector|state_pesticide||7.9|| +state_pesticide_79038223|branch|53fce420559577f9|49679374232582c0|14cd87614565fa4d|-923057110||t19836.0977858266s|1343b86bc4b2ef88|82393|qs|local|vector|state_pesticide||5.266|| +state_pesticide_79d32c3e|branch|bd66764e7e2041fb|49679374232582c0|14cd87614565fa4d|-293175114||t19836.0981394806s|202453ce10c2cec2|45632|qs|local|vector|state_pesticide||3.701|| +state_pesticide_7a46c38b|branch|f710d295af9ea5d3|49679374232582c0|14cd87614565fa4d|-919821490||t19836.0975180139s|ddf4b5f9ab9f452f|59165|qs|local|vector|state_pesticide||5.69|| +state_pesticide_7d6ceee4|branch|9e15beec6581c70a|49679374232582c0|14cd87614565fa4d|721551165||t19836.0974983384s|b4824669223a109b|29578|qs|local|vector|state_pesticide||2.981|| +state_pesticide_8622c393|branch|86faf2e839bdb154|49679374232582c0|14cd87614565fa4d|-520957089||t19836.0978656441s|866c3d65a792f2f1|32870|qs|local|vector|state_pesticide||5.425|| +state_pesticide_8dfcc088|branch|efdfe931ee3c2259|49679374232582c0|14cd87614565fa4d|-1720445271||t19836.0977701678s|cb9601ce92a5e2d4|30937|qs|local|vector|state_pesticide||3.05|| +state_pesticide_9ff905dc|branch|a4d19dc6c246105e|49679374232582c0|14cd87614565fa4d|1672283516||t19836.0980561223s|41a317c52ee23b5a|11818|qs|local|vector|state_pesticide||4.092|| +state_pesticide_aa680b60|branch|3f27dfa3253484f8|49679374232582c0|14cd87614565fa4d|-1551046146||t19836.0978521889s|e688638f1d6619ab|17468|qs|local|vector|state_pesticide||2.509|| +state_pesticide_b1557609|branch|af7e7f02b38f33d5|49679374232582c0|14cd87614565fa4d|-1934674019||t19836.0979206434s|8ddeab211e700d8d|53332|qs|local|vector|state_pesticide||4.719|| +state_pesticide_b3298e34|branch|20be6d74132022c3|49679374232582c0|14cd87614565fa4d|-1170343882||t19836.09777111s|52968c5f64bc90f3|203900|qs|local|vector|state_pesticide||12.815|| +state_pesticide_b55cc252|branch|09e58d08b9f75235|49679374232582c0|14cd87614565fa4d|53519870||t19836.0981115301s|2e092d8d059dbf88|88953|qs|local|vector|state_pesticide||7.005|| +state_pesticide_baa73d14|branch|df87ced496934fd9|49679374232582c0|14cd87614565fa4d|-1425466781||t19836.0977044127s|4bb0a734f6667909|56970|qs|local|vector|state_pesticide||5.573|| +state_pesticide_be78befd|branch|012fdfa504224028|49679374232582c0|14cd87614565fa4d|732950819||t19836.0981648413s|0c97535a2b729965|17859|qs|local|vector|state_pesticide||2.192|| +state_pesticide_bfc1f1c7|branch|a25eefce5db150c0|49679374232582c0|14cd87614565fa4d|-586376084||t19836.0980024923s|72dd6a4f619acc0e|37898|qs|local|vector|state_pesticide||4.38|| +state_pesticide_bfe72e55|branch|d496156db91bef49|49679374232582c0|14cd87614565fa4d|-342488832||t19836.097892621s|c4f4a0e22e89073f|769079|qs|local|vector|state_pesticide||45.53|| +state_pesticide_c988cda9|branch|04567148468738f2|49679374232582c0|14cd87614565fa4d|-254112269||t19836.0980090722s|47836972f57b2e65|166429|qs|local|vector|state_pesticide||8.988|| +state_pesticide_cc3b828c|branch|6dd71d12008128c1|49679374232582c0|14cd87614565fa4d|745296327||t19836.0976394037s|de1c6d017cb4e8a8|38|qs|local|vector|state_pesticide||1.114|| +state_pesticide_combined|stem|674c15c22de489b2|ecbaceb6dd1acf4e|6178bb7c0316a791|-248763802||t19836.0982912064s|86e4b55d9c0e3fd8|2526315|qs|local|vector|||0.002|| +state_pesticide_d3af20cb|branch|f910147640094353|49679374232582c0|14cd87614565fa4d|-934136572||t19836.0981558886s|f298e23f5e91ed15|28987|qs|local|vector|state_pesticide||3.439|| +state_pesticide_daf72072|branch|6beaaa0df74723c4|49679374232582c0|14cd87614565fa4d|-825099448||t19836.098230046s|4edd1ba0f82f6966|86760|qs|local|vector|state_pesticide||5.583|| +state_pesticide_e4130b01|branch|030fc8a3c4f63d36|49679374232582c0|14cd87614565fa4d|-67432851||t19836.0975632662s|fcbd7443b7cbeb00|46121|qs|local|vector|state_pesticide||5.595|| +state_pesticide_e4c3e020|branch|505805ae07b11c98|49679374232582c0|14cd87614565fa4d|979591373||t19836.0978027692s|4f4366d1ec26be13|29346|qs|local|vector|state_pesticide||2.807|| +state_pesticide_fa5f609e|branch|2860645396fe8ece|49679374232582c0|14cd87614565fa4d|-180838893||t19836.0978230168s|d014524ea30b0a92|16713|qs|local|vector|state_pesticide||3.221|| +state_pesticide_fd520386|branch|6704d1ace0302c5d|49679374232582c0|14cd87614565fa4d|2126256019||t19836.0979519087s|a4a73eee77613473|110995|qs|local|vector|state_pesticide||8.565|| sub_sample_data|stem|cb4dafe8e72dc057|e6889750cd2bc8b1|72365e51e29ffb76|-1343935607||t19828.8715966331s|2150ddb218ea6913|11271814|qs|local|vector|||0.199|| sub_sp_kfold|stem|98a05c7bf5177ecc|ad4d2011f9458490|18a4543fecd86687|931115772||t19828.8840616909s|360d18428238e673|33827832|qs|local|vector|||0.148|| sub_time_kfold|stem|fdbd8d62d925251c|8eec82477744024d|18a4543fecd86687|1303279051||t19828.8840530324s|8bb70abf7f094445|22551259|qs|local|vector|||0.023|| temporal_kfold|stem|0dff82ff4d38fcce|85d2fb6951fc0175|72365e51e29ffb76|-92770833||t19828.8204739513s|84009b2414f8003e|1938008400|qs|local|vector|||0.135|| unique_vals|function|ac6736f8d13d8c75||||||||||||||| -wbd_data|stem|76673de8c6d73bc6|874b01544380a4da|ef46db3751d8e999|1549743976||t19832.8302430556s|de1c6d017cb4e8a8|38|qs|local|vector|||1122.972|| +wbd_data|stem|1eb746438131e803|d56b9303ca10feec|ef46db3751d8e999|1549743976|input/wmd_national/WBD_National_GDB/WBD_National_GDB.gdb|t19836.1634607845s|54e3e0c83ad40907|5056|file|local|vector|||0.198|| wbd_unzip|stem||ba884de09738181f|6557a7f85b28d2df|949254395||t19832.8584534035s||0|qs|local|vector|||0.004||invalid zip name argument +fit_lasso|function|9be9d8a163a801b5 +get_censored_data|function|8ca2ae23defd8bd9 +covariate_prep|function|c9eca70c452240cc +calc_olm|function|f6964f4b260356a3 +fit_MV_Vecchia|function|769c672b111646a4 +create_olm_combined|function|2a0af497a54abfd2 +combine_state_data|function|7df828cef5aac723 +pivot_covariates|function|6664f2b8836c0d3a +prepare_pesticide_for_fit|function|6f5e8efe0a873399 +plot_outcome_map|function|b80a2cef2acf46ab +partition_datasets|function|6c216a0d6f2c2064 +.Random.seed|object|2d83f829ed68a82c +get_yearly_averages|function|85fec8feff4be03b +join_pesticide_huc|function|69639db1e5419739 +plot_pesticide_ridges|function|de44b6072d7db81e +lasso_spatial_kfold_fit|function|db2c7bfd885d9600 +plot_exploratory_covariates|function|d0e73c2697565698 +state_fun_AZO|function|cc0ee1a0aed422c7 +olm_read_crop|function|f7d7c25dbcb60964 +plot_cv_map|function|7f6f6a570bd5ad27 +get_daily_averages|function|654656d6dff55080 diff --git a/code/02_Geographic_Covariates/Calc_OLM.R b/code/02_Geographic_Covariates/Calc_OLM.R index f017645..be36b35 100644 --- a/code/02_Geographic_Covariates/Calc_OLM.R +++ b/code/02_Geographic_Covariates/Calc_OLM.R @@ -1,51 +1,28 @@ -calc_olm <- function(data.AZO){ +calc_olm <- function(data.AZO, wbd_data, hucunit, bulk_density, clay, oc, pH, sand, soil_order, texture){ - # use the PrestoGP_Pesticide/ path for input data - It's okay - # Use static-branching to create a qs dataset per raster + layername <- paste0("WBD", toupper(gsub("c", "", hucunit))) - ## HUCUNIT - HUCUNIT <- "huc10" - layername <- paste0("WBD", toupper(gsub("c", "", HUCUNIT))) - - ## ----pesticide and NHD WBD data, echo=FALSE----------------------------------- - # Read in main pesticide data here - #data.AZO <- sf::st_read(paste0(path_base, "./data_process/data_AZO_watershed_huc_join.shp")) # # For efficient extraction, we just need the geometry AZO.geometry <- sf::st_geometry(data.AZO) - # # US bounding box - US.bb <- terra::ext(c(-124.7844079, -66.9513812, 24.7433195, 49.3457868)) - + # # NHD WBD Layer names - WBD.layers <- st_layers(paste0(path_base, "WBD_National_GPKG.gpkg")) - - WBD <- st_read(paste0(path_base, "WBD_National_GPKG.gpkg"), layer = layername) %>% + WBD <- sf::st_read(wbd_data, layer = layername) %>% st_transform("EPSG:4326") - ## ----OLM raster data,echo=FALSE----------------------------------------------- - # Cropped Raster directory - # cropped.raster.dir <- "/Volumes/SHAG/OpenLandMapData/OLM_Combined/" - cropped.raster.dir <- ""#"OpenLandMapData/OLM_Combined/" - crop.dir <- paste0(path_base, cropped.raster.dir) - - - - - # Combine the rasters in which we are calculating a mean value into one raster stack with # many layers OLM.stack.values <- c( - pH.stack, Clay_Content.stack, Bulk_Density.stack, Sand_Content.stack, - Organic_Carbon.stack, soil_order.stack + bulk_density, clay, oc, pH, sand, soil_order ) - OLM.stack.classes <- texture.stack + OLM.stack.classes <- texture - # The soil texturer needs updating of its class names + # The soil texture needs updating of its class names texture_classes <- data.frame("classes" = c( "clay", "silty_clay", "sandy_clay", @@ -69,20 +46,16 @@ calc_olm <- function(data.AZO){ ## ----Calculate exact grid points ,echo=TRUE----------------------------------- - # HUC08 - # get the given HUC08 geometry from the WBD data - # huc08.polygon <- dplyr::filter(WBD, huc8 == huc08.unique[i]) - huc08.polygon <- WBD - #sf::read_sf(paste0(path_base, "WBD_National_GPKG.gpkg"), layer = "WBDHU8") - + + huc_polygon <- WBD + HUC.nulltable <- data.table() - HUC.rast.vals <- HUC.nulltable[, (HUCUNIT) := unlist(huc08.polygon[[HUCUNIT]])] - - # huc08.unique <- unique(data.AZO$huc08) + HUC.rast.vals <- HUC.nulltable[, (hucunit) := unlist(huc_polygon[[hucunit]])] - HUC.rast.vals[, paste0(HUCUNIT, ".", names(OLM.stack.values)) := NA_real_] + + HUC.rast.vals[, paste0(hucunit, ".", names(OLM.stack.values)) := NA_real_] - HUC.rast.class <- HUC.nulltable[, (HUCUNIT) := unlist(huc08.polygon[[HUCUNIT]])] + HUC.rast.class <- HUC.nulltable[, (hucunit) := unlist(huc_polygon[[hucunit]])] class.df <- expand.grid(levels(OLM.stack.classes)[[1]]$ID, c( "Texture_000cm", "Texture_010cm", "Texture_030cm", @@ -93,7 +66,7 @@ calc_olm <- function(data.AZO){ class.possible.names <- paste0("frac_", class.df$Var1, ".", class.df$Var2) - HUC.rast.class[, paste0(HUCUNIT, ".", class.possible.names) := 0] + HUC.rast.class[, paste0(hucunit, ".", class.possible.names) := 0] # for (i in 1:length(huc08.unique)) { # print(i) @@ -103,13 +76,13 @@ calc_olm <- function(data.AZO){ # calculate the mean raster values in the HUC - huc08.val <- exact_extract(OLM.stack.values, st_geometry(huc08.polygon), fun = "mean", stack_apply = TRUE) + huc08.val <- exact_extract(OLM.stack.values, st_geometry(huc_polygon), fun = "mean", stack_apply = TRUE) # Assign the extracted values to the appropriate location in the output HUC.rast.vals[, 2:ncol(HUC.rast.vals)] <- huc08.val # calculate the fraction of each raster class in the HUC - extract.raster.classes <- exact_extract(OLM.stack.classes, st_geometry(huc08.polygon), fun = "frac", stack_apply = TRUE) + extract.raster.classes <- exact_extract(OLM.stack.classes, st_geometry(huc_polygon), fun = "frac", stack_apply = TRUE) # # get indexs - for columns of outout - where classes match the output idx.col <- which(class.possible.names %in% colnames(extract.raster.classes)) + 1 @@ -125,12 +98,12 @@ calc_olm <- function(data.AZO){ rename_with(function(x) str_replace_all(x, "_{2}", "_")) %>% rename_with(function(x) str_replace_all(x, "sol_order_usda_soiltax_", "")) %>% rename_with(function(x) str_replace_all(x, "_1950_2017_v0_1", "")) %>% - select(-!!sym(HUCUNIT)) + select(-!!sym(hucunit)) # Classes column names updates HUC.rast.class <- HUC.rast.class %>% rename_with(function(x) str_replace_all(x, "[.]", "_")) %>% - select(-!!sym(HUCUNIT)) + select(-!!sym(hucunit)) # Rename the number with the class name - ugly but it works HUC.rast.class <- dplyr::rename_with(HUC.rast.class, ~ gsub("frac_1_", paste0("frac_", texture_classes$classes[1], "_"), .x, fixed = TRUE)) %>% @@ -148,96 +121,17 @@ calc_olm <- function(data.AZO){ ## ----Save the data to a geopackage (OSG open source format) ,echo=TRUE-------- - data.AZO.HUC08.OLM <- cbind(HUC08=unlist(huc08.polygon[[HUCUNIT]]), HUC.rast.vals, HUC.rast.class) - names(data.AZO.HUC08.OLM)[1] <- HUCUNIT + data.AZO.HUC08.OLM <- cbind(HUC08=unlist(huc_polygon[[hucunit]]), HUC.rast.vals, HUC.rast.class) + names(data.AZO.HUC08.OLM)[1] <- hucunit return(data.AZO.HUC08.OLM) } - -create_olm_combined <- function(path){ - +olm_read_crop <- function(olm_data){ # # US bounding box US.bb <- terra::ext(c(-124.7844079, -66.9513812, 24.7433195, 49.3457868)) - - - # Directories of individual raw OLM data - OLM.dir.pH <- "input/OpenLandMapData/pH" - OLM.dir.Clay_Content <- "input/OpenLandMapData/Clay_Content" - OLM.dir.Bulk_Density <- "input/OpenLandMapData/Bulk_Density" - OLM.dir.Sand_Content <- "input/OpenLandMapData/Sand_Content" - OLM.dir.Organic_Carbon <- "input/OpenLandMapData/Organic_Carbon" - OLM.dir.Soil_Order <- "input/OpenLandMapData/Soil_Order" - OLM.dir.Texture <- "input/OpenLandMapData/USDA_Texture_Class" - - - # Get Raster data filenames/paths - OLM.filenames.pH <- list.files( - path = OLM.dir.pH, - pattern = "*.tif", full.names = T - ) - - pH.stack <- terra::rast(OLM.filenames.pH) %>% terra::crop(US.bb) - - # - OLM.filenames.Clay_Content <- list.files( - path = OLM.dir.Clay_Content, - pattern = "*.tif", full.names = T - ) - - Clay_Content.stack <- terra::rast(OLM.filenames.Clay_Content) %>% terra::crop(US.bb) - - # - OLM.filenames.Bulk_Density <- list.files( - path = OLM.dir.Bulk_Density, - pattern = "*.tif", full.names = T - ) - - Bulk_Density.stack <- terra::rast(OLM.filenames.Bulk_Density) %>% terra::crop(US.bb) - - # - OLM.filenames.Sand_Content <- list.files( - path = OLM.dir.Sand_Content, - pattern = "*.tif", full.names = T - ) - - Sand_Content.stack <- terra::rast(OLM.filenames.Sand_Content) %>% terra::crop(US.bb) - - # - OLM.filenames.Organic_Carbon <- list.files( - path = OLM.dir.Organic_Carbon, - pattern = "*.tif", full.names = T - ) - - Organic_Carbon.stack <- terra::rast(OLM.filenames.Organic_Carbon) %>% terra::crop(US.bb) - - # - OLM.filenames.Soil_Order <- list.files( - path = OLM.dir.Soil_Order, - pattern = "*.tif", full.names = T - ) - - soil_order.stack <- terra::rast(OLM.filenames.Soil_Order) %>% terra::crop(US.bb) - - # - OLM.filenames.Texture <- list.files( - path = OLM.dir.Texture, - pattern = "*.tif", full.names = T - ) - - texture.stack <- terra::rast(OLM.filenames.Texture) %>% terra::crop(US.bb) - - - # Write the cropped rasters for future use and time saving - writeRaster(pH.stack, "input/OpenLandMapData/OLM_Combined/OLM_US_Crop_pH.tif") - writeRaster(Clay_Content.stack, "input/OpenLandMapData/OLM_Combined/OLM_US_Crop_Clay_Content.tif") - writeRaster(Bulk_Density.stack, "input/OpenLandMapData/OLM_Combined/OLM_US_Crop_Bulk_Density.tif") - writeRaster(Sand_Content.stack, "input/OpenLandMapData/OLM_Combined/OLM_US_Crop_Sand_Content.tif") - writeRaster(Organic_Carbon.stack, "input/OpenLandMapData/OLM_Combined/OLM_US_Crop_Organic_Carbon.tif") - writeRaster(soil_order.stack, "input/OpenLandMapData/OLM_Combined/OLM_US_Crop_Soil_Order.tif") - writeRaster(texture.stack, "input/OpenLandMapData/OLM_Combined/OLM_US_Crop_Soil_Texture_Class.tif") - - -} \ No newline at end of file + stack <- terra::rast(olm_data) %>% terra::crop(US.bb) + return(stack) +} diff --git a/code/03_Pesticide_Analysis/Target_Helpers.R b/code/03_Pesticide_Analysis/Target_Helpers.R index 2956b51..3156f75 100644 --- a/code/03_Pesticide_Analysis/Target_Helpers.R +++ b/code/03_Pesticide_Analysis/Target_Helpers.R @@ -3,18 +3,21 @@ -join_pesticide_huc <- function(points){ +join_pesticide_huc <- function(points, wbd_huc){ - HUC12 <- sf::st_read("input/WBD-National/WBD_National_GDB/WBD_National_GDB.gdb", layer = "WBDHU12") + HUC12 <- sf::st_read(wbd_huc, layer = "WBDHU12") # Convert both the AZO points and HUC to Albers Equal Area projected coordinate system - AZO.t <- sf::st_transform(points, "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 -+ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") +# AZO.t <- sf::st_transform(points, "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +# +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") + AZO.t <- sf::st_transform(points, crs = st_crs(HUC12)) - huc.t <- sf::st_transform(HUC12, "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 -+ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") + - AZO.HUC.join <- sf::st_join(AZO.t, huc.t) + AZO.HUC.join <- sf::st_join(AZO.t, HUC12) + + AZO.HUC.join <- sf::st_transform(AZO.HUC.join, "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 ++ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") AZO.HUC.join$huc10 <- str_sub(AZO.HUC.join$huc12, 1, 10) AZO.HUC.join$huc08 <- str_sub(AZO.HUC.join$huc12, 1, 8)