-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorksheet.R
More file actions
127 lines (107 loc) · 3.23 KB
/
Copy pathWorksheet.R
File metadata and controls
127 lines (107 loc) · 3.23 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
library(icesTAF)
library(dplyr)
library(sf)
library(ggplot2)
#get data
data(trees)
write.csv(cars, "cars.csv")
write.csv(trees, "trees.csv")
#Create the TAF skeleton R files
taf.skeleton()
#copy a file from a local source
cp("cars.csv", "bootstrap/initial/data")
# document data
draft.data(
data.files = "trees.csv",
originator = "Ryan, T. A., Joiner, B. L. and Ryan, B. F. (1976) The Minitab Student Handbook. Duxbury Press.",
title = "Diameter, Height and Volume for Black Cherry Trees",
file = TRUE,
append = FALSE
)
# download gridded netcdf SST data from UK Met office
library(icesTAF)
download.file(
"https://www.metoffice.gov.uk/hadobs/hadsst4/data/netcdf/HadSST.4.0.1.0_median.nc",
mode = "wb",
destfile = "HadSST.4.0.1.0_median.nc"
)
download(
"https://www.metoffice.gov.uk/hadobs/hadsst4/data/netcdf/HadSST.4.0.1.0_median.nc"
)
draft.data(
data.files = "HadSST.4.0.1.0_median.nc",
originator = "UK MET office",
title = "Met Office Hadley Centre observations datasets",
year = 2022,
source = "https://www.metoffice.gov.uk/hadobs/hadsst4/data/netcdf/HadSST.4.0.1.0_median.nc",
file = TRUE,
append = TRUE
)
draft.data(
data.files = "ICES_Areas_20160601_cut_dense_3857.shp",
originator = "ICES",
title = "ICES Areas",
year = 2016,
source = "http://gis.ices.dk/shapefiles/ICES_areas.zip",
file = TRUE,
append = TRUE
)
# use a folder of initial data
# ------
# create a data collection (i.e. a folder of related files which will have BIB entry)
mkdir("bootstrap/initial/data/data-collection/")
cp(
"D:/taf-workshop/taf-workshop-example-1/bootstrap/initial/data/*",
"bootstrap/initial/data/data-collection/"
)
draft.data(
data.files = "data-collection",
originator = "R datasets package",
title = "Collection of R data",
source = "folder",
file = TRUE,
append = TRUE # create a new DATA.bib
)
taf.bootstrap(software = FALSE)
#bring in an online file
# UK met offices on sea surface temperature
download.file(
"https://www.metoffice.gov.uk/hadobs/hadsst4/data/netcdf/HadSST.4.0.1.0_median.nc",
mode = "wb",
destfile = "HadSST.4.0.1.0_median.nc"
)
# document the data
draft.data(
data.files = "trees.csv",
originator = "Ryan, T. A., Joiner, B. L. and Ryan, B. F. (1976) The Minitab Student Handbook. Duxbury Press.",
title = "Diameter, Height and Volume for Black Cherry Trees",
file = TRUE,
append = FALSE
)
draft.data(
data.files = "cars.csv",
originator = "cars",
title = "cars",
file = TRUE,
append = T
)
draft.data(
data.files = "HadSST.4.0.1.0_median.nc",
originator = "UK MET office",
title = "Met Office Hadley Centre observations datasets",
year = 2022,
source = "https://www.metoffice.gov.uk/hadobs/hadsst4/data/netcdf/HadSST.4.0.1.0_median.nc",
file = TRUE,
append = TRUE
)
# check bootstrap works as we work, moves initial data files to the bootstrap data, where you should work from now on
# taf.bootstrap runs the procedure but does not reinstate everything only data from the initial data folder
taf.bootstrap()
download.file(
"http://gis.ices.dk/shapefiles/ICES_areas.zip",
"temp.zip")
unzip("temp.zip")
unlink("temp.zip")
#download("http://gis.ices.dk/shapefiles/ICES_area.zip")
#unzip("ICES_area.zip")
areas <- sf::st_read("ICES_Areas_20160601_cut_dense_3857.shp")