From de78eeef3b1e9196f58a7615f993ddd68caa1040 Mon Sep 17 00:00:00 2001 From: elmeraa <eazadpour@usgs.gov> Date: Mon, 18 Dec 2023 11:15:19 -0800 Subject: [PATCH] set up repo and read in vulnerability indicators data --- .gitignore | 27 +++++++++++++++++++++++++++ 1_fetch.R | 23 +++++++++++++++++++++++ 1_fetch/in/.empty | 0 1_fetch/out/.empty | 0 1_fetch/src/.empty | 0 2_process.R | 7 +++++++ 2_process/in/.empty | 0 2_process/out/.empty | 0 2_process/src/.empty | 0 3_visualize.R | 6 ++++++ 3_visualize/.empty | 0 3_visualize/in/.empty | 0 3_visualize/out/.empty | 0 _targets.R | 24 ++++++++++++++++++++++++ vulnerability-indicators.Rproj | 13 +++++++++++++ 15 files changed, 100 insertions(+) create mode 100644 .gitignore create mode 100644 1_fetch.R create mode 100644 1_fetch/in/.empty create mode 100644 1_fetch/out/.empty create mode 100644 1_fetch/src/.empty create mode 100644 2_process.R create mode 100644 2_process/in/.empty create mode 100644 2_process/out/.empty create mode 100644 2_process/src/.empty create mode 100644 3_visualize.R create mode 100644 3_visualize/.empty create mode 100644 3_visualize/in/.empty create mode 100644 3_visualize/out/.empty create mode 100644 _targets.R create mode 100644 vulnerability-indicators.Rproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9962c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +.Rproj.user +.Rproj.user/ +.Rhistory +.RData +.Ruserdata +.RProfile +.Renvironment +.DS_Store +1_fetch/out/* +1_fetch/in/* +1_fetch/src/* +2_process/in/* +2_process/src/* +2_process/out/* +3_visualize/in/* +3_visualize/src/* +3_visualize/out/* +!1_fetch/in/.empty +!1_fetch/src/.empty +!1_fetch/out/.empty +!2_process/in/.empty +!2_process/src/.empty +!2_process/out/.empty +!3_visualize/in/.empty +!3_visualize/src/.empty +!3_visualize/out/.empty +_targets/ diff --git a/1_fetch.R b/1_fetch.R new file mode 100644 index 0000000..feff5e3 --- /dev/null +++ b/1_fetch.R @@ -0,0 +1,23 @@ +source("1_fetch/src/fetch_utils.R") + +p1_targets <- list( + ##### Vulnerability indicators data ##### + tar_target(p1_sb_id, + '63f79d49d34e4f7eda456572'), + ##### Vulnerability indicators metadata ##### + tar_target(p1_vul_ind_xml, + download_from_sb(sb_id = p1_sb_id, + filename = 'Uncertainty_Summary.xml', + dest_dir = '1_fetch/out'), + format = 'file'), + ##### Uncertainty statistics for the indicators ##### + tar_target(p1_unc_stats_csv, + download_from_sb(sb_id = p1_sb_id, + filename = 'Uncertainty_Summary.csv', + dest_dir = '1_fetch/out'), + format = 'file'), + tar_target(p1_unc_stats, + readr::read_csv(p1_unc_stats_csv) |> + janitor::clean_names() + ) + ) \ No newline at end of file diff --git a/1_fetch/in/.empty b/1_fetch/in/.empty new file mode 100644 index 0000000..e69de29 diff --git a/1_fetch/out/.empty b/1_fetch/out/.empty new file mode 100644 index 0000000..e69de29 diff --git a/1_fetch/src/.empty b/1_fetch/src/.empty new file mode 100644 index 0000000..e69de29 diff --git a/2_process.R b/2_process.R new file mode 100644 index 0000000..69c9e99 --- /dev/null +++ b/2_process.R @@ -0,0 +1,7 @@ +# source('1_fetch/src/file_utils.R') +# source('2_process/src/spatial_utils.R') +# source('2_process/src/data_utils.R') + +p2_targets <- list( + +) \ No newline at end of file diff --git a/2_process/in/.empty b/2_process/in/.empty new file mode 100644 index 0000000..e69de29 diff --git a/2_process/out/.empty b/2_process/out/.empty new file mode 100644 index 0000000..e69de29 diff --git a/2_process/src/.empty b/2_process/src/.empty new file mode 100644 index 0000000..e69de29 diff --git a/3_visualize.R b/3_visualize.R new file mode 100644 index 0000000..6a4f6c4 --- /dev/null +++ b/3_visualize.R @@ -0,0 +1,6 @@ +# source('1_fetch/src/file_utils.R') +# source('3_visualize/src/plot_utils.R') + +p3_targets <- list( + +) \ No newline at end of file diff --git a/3_visualize/.empty b/3_visualize/.empty new file mode 100644 index 0000000..e69de29 diff --git a/3_visualize/in/.empty b/3_visualize/in/.empty new file mode 100644 index 0000000..e69de29 diff --git a/3_visualize/out/.empty b/3_visualize/out/.empty new file mode 100644 index 0000000..e69de29 diff --git a/_targets.R b/_targets.R new file mode 100644 index 0000000..ef873ec --- /dev/null +++ b/_targets.R @@ -0,0 +1,24 @@ +library(targets) +library(tarchetypes) # need version >= 0.6.0.9000 + +options(tidyverse.quiet = TRUE, timeout = 800) +tar_option_set(packages = c('tidyverse', + 'sf', + 'terra', + 'rmapshaper', + 'purrr', + 'raster', + 'magick', + 'janitor', + 'sbtools')) + +# Phase target makefiles +source("1_fetch.R") +source("2_process.R") +source("3_visualize.R") + +# Combined list of target outputs +c(p1_targets, + p2_targets, + p3_targets +) \ No newline at end of file diff --git a/vulnerability-indicators.Rproj b/vulnerability-indicators.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/vulnerability-indicators.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX -- GitLab