-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc_file_transfer_functions.R
83 lines (66 loc) · 3.3 KB
/
misc_file_transfer_functions.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#####uploading####
library(googledrive)
#this is the path to a folder in my google drive with 3 TB storage
checkGPath <- function(gdriveFolder){
checkPath <- drive_get(gdriveFolder)
if (length(checkPath$name) == 0){
thePath <- googledrive::drive_mkdir(gdriveFolder)
}
thePath <- as_dribble(gdriveFolder)
}
if (FALSE){
#if you run this, it will overwrite the files in googledrive
toZip <- list.files("outputs/raw", full.names = TRUE)
utils::zip(zipfile = "outputs/raw.zip",
files = toZip,
flags = "-j")
rawPath <- as_dribble(file.path(gDrivePath, "raw habitat layers"))
drive_put("outputs/raw.zip", path = rawPath)
toZip <- list.files("outputs/weightedHabitat", full.names = TRUE)
utils::zip(zipfile = "outputs/weightedHabitat.zip",
files = toZip,
flags = "-j")
weightedPath <- as_dribble(file.path(gDrivePath, "weighted habitat"))
drive_put("outputs/weightedHabitat.zip", path = weightedPath)
toZip <- list.files("outputs/compositeHabitat", full.names = TRUE)
utils::zip(zipfile = "outputs/compositeHabitat.zip",
files = toZip,
flags = "-j")
compositePath <- as_dribble(file.path(gDrivePath, "composite habitat"))
drive_put("outputs/compositeHabitat.zip", path = compositePath)
toZip <- list.files("outputs/weightedDifference", full.names = TRUE)
utils::zip(zipfile = "outputs/weightedDifference.zip",
files = toZip,
flags = "-j")
weightedChangePath <- as_dribble(file.path(gDrivePath, "change in weighted habitat"))
drive_put("outputs/weightedDifference.zip", path = weightedChangePath)
}
####downloading####
#moving files off google drive
results <- drive_ls(as_id("https://drive.google.com/drive/folders/1bqXed21z922H1cQv_1jTh8RN0BdyK0OY"),
recursive = TRUE)
FileID <- results[results$name == "weightedHabitat.zip",]$id
googledrive::drive_download(file = FileID,
path = "outputs/weightedHabitat.zip", overwrite = TRUE)
utils::unzip(zipfile = "outputs/weightedHabitat.zip", exdir = "outputs/weightedHabitat", overwrite = TRUE)
FileID <- results[results$name == "compositeHabitat.zip",]$id
googledrive::drive_download(file = FileID,
path = "outputs/compositeHabitat.zip", overwrite = TRUE)
utils::unzip(zipfile = "outputs/compositeHabitat.zip", exdir = "outputs/compositeHabitat", overwrite = TRUE)
FileID <- results[results$name == "nonHabitat_Masks.zip",]$id
googledrive::drive_download(file = FileID,
path = "outputs/nonHabitat_Masks.zip")
utils::unzip(zipfile = "outputs/nonHabitat_masks.zip", exdir = "outputs/masks")
FileID <- results[results$name == "weightedDifference.zip",]$id
googledrive::drive_download(file = FileID,
path = "outputs/weightedDifference.zip",
overwrite = TRUE)
utils::unzip(zipfile = "outputs/weightedDifference.zip",
exdir = "outputs/weightedDifference",
overwrite = TRUE)
FileID <- results[results$name == "focalHabitat1000.zip",]$id
googledrive::drive_download(file = FileID,
path = "outputs/focalHabitat1000.zip")
utils::unzip(zipfile = "outputs/focalHabitat1000.zip", exdir = "outputs/focalHabitat1000")
out <- googledrive::drive_get(path = gDrivePath)
out$name