From 010602418e08d51040f16be97b0759c84a68de45 Mon Sep 17 00:00:00 2001 From: kauedesousa Date: Tue, 30 Jan 2024 15:21:34 +0100 Subject: [PATCH] move-spam-files --- .gitignore | 2 ++ script/01.1-move-spam-files.R | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 script/01.1-move-spam-files.R diff --git a/.gitignore b/.gitignore index 24b1bea..3c85c20 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ token/api-key.txt data/wc2.1-global ecocrop-raw ecocrop +data/SPAM + diff --git a/script/01.1-move-spam-files.R b/script/01.1-move-spam-files.R new file mode 100644 index 0000000..a982a6d --- /dev/null +++ b/script/01.1-move-spam-files.R @@ -0,0 +1,24 @@ +library("geodata") + +from = "/Users/kauedesousa/local-workflow/geo-raster-shapefile/spam2010v2r0_global_harv_area/" + +here = "data/SPAM/" + +crops = read.csv("data/mapspam-crop-names.csv") + +crops = toupper(crops$spamname) + +identifier = paste(crops, collapse = "|") + +files = list.files(from, pattern = identifier, full.names = TRUE) + +f = grep("H.tif$|A.tif$", files) + +f = files[f] + +n = gsub(from, "", f) + +file.copy(f, paste0(here, n)) + + +