Skip to content

Commit

Permalink
added TAF example for reading data
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Dag Pohlmann committed Jun 14, 2022
1 parent dd13aa9 commit 6bf0161
Show file tree
Hide file tree
Showing 41 changed files with 1,600 additions and 512 deletions.
Binary file modified .RData
Binary file not shown.
1,024 changes: 512 additions & 512 deletions .Rhistory

Large diffs are not rendered by default.

Binary file added Misc/WKTAF/Example/.RData
Binary file not shown.
197 changes: 197 additions & 0 deletions Misc/WKTAF/Example/.Rhistory
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
setwd("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example")
library(icesTAF)
#creates folder structure
taf.skeleton()
#move script(s) that are used to import data to the bootstrap folder
invisible(file.copy("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/sample_files/ices-areas.R", "C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example/bootstrap/ices-areas.R"))
# create metadata
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 # create a new DATA.bib
)
# create metadata (add to previous BATA.bib)
draft.data(
data.files = "HadSST.4.0.1.0_median.nc", #can be a folder with multiple files
originator = "UK MET office",
title = "Met office observations data set",
source = "https://www.metoffice.gov.uk/hadobs/hadsst4/data/netcdf/HadSST.4.0.1.0_median.nc",
year = 2022,
file = TRUE,
append = TRUE # append to existing DATA.bib
)
draft.data(
data.files = "collection", #give name of a folder
originator = "myself",
title = "empty sheets",
source = "folder", #write folder if it is a folder
year = 2022,
file = TRUE,
append = TRUE # append to existing DATA.bib
)
#bring in data from script
draft.data(
data.files = NULL,
data.scripts = "ices-areas.R", # this needs to be in the bootstrap folder
originator = "ICES",
title = "ICES areas",
file = TRUE,
append = TRUE
)
# create metadata
draft.data(
data.files = "trees.csv",
data.scripts = NULL,
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 # create a new DATA.bib
)
# create metadata (add to previous BATA.bib)
draft.data(
data.files = "HadSST.4.0.1.0_median.nc", #can be a folder with multiple files
originator = "UK MET office",
data.scripts = NULL,
title = "Met office observations data set",
source = "https://www.metoffice.gov.uk/hadobs/hadsst4/data/netcdf/HadSST.4.0.1.0_median.nc",
year = 2022,
file = TRUE,
append = TRUE # append to existing DATA.bib
)
draft.data(
data.files = "collection", #give name of a folder
originator = "myself",
data.scripts = NULL,
title = "empty sheets",
source = "folder", #write folder if it is a folder
year = 2022,
file = TRUE,
append = TRUE # append to existing DATA.bib
)
#bring in data from script
draft.data(
data.files = NULL,
data.scripts = "ices-areas.R", # this needs to be in the bootstrap folder
originator = "ICES",
title = "ICES areas",
file = TRUE,
append = TRUE
)
setwd("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example")
#install.packages("icesTAF")
library(icesTAF)
#creates folder structure
taf.skeleton()
#move script(s) that are used to import data to the bootstrap folder
invisible(file.copy("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/sample_files/ices-areas.R", "C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example/bootstrap/ices-areas.R"))
###############-----------1. create metadata----------################### (.bib file)
# create metadata
draft.data(
data.files = "trees.csv",
data.scripts = NULL,
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 # create a new DATA.bib
)
# create metadata (add to previous BATA.bib)
draft.data(
data.files = "HadSST.4.0.1.0_median.nc", #can be a folder with multiple files
originator = "UK MET office",
data.scripts = NULL,
title = "Met office observations data set",
source = "https://www.metoffice.gov.uk/hadobs/hadsst4/data/netcdf/HadSST.4.0.1.0_median.nc",
year = 2022,
file = TRUE,
append = TRUE # append to existing DATA.bib
)
draft.data(
data.files = "collection", #give name of a folder
originator = "myself",
data.scripts = NULL,
title = "empty sheets",
source = "folder", #write folder if it is a folder
year = 2022,
file = TRUE,
append = TRUE # append to existing DATA.bib
)
#bring in data from script
draft.data(
data.files = NULL,
data.scripts = "ices-areas.R", # this needs to be in the bootstrap folder
originator = "ICES",
title = "ICES areas",
file = TRUE,
append = TRUE
)
##################----------------bring in initial data----------------#########################
#bring in a local file from elsewhere (to initial/data)
cp("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/sample_files/trees.csv", "bootstrap/initial/data/")
#download data
download("https://www.metoffice.gov.uk/hadobs/hadsst4/data/netcdf/HadSST.4.0.1.0_median.nc", dir = "C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example/bootstrap/initial/data")
##################----------------copy initial data to actual data folder (basically a copy to work with----------------#########################
taf.bootstrap(software = FALSE) #brings all data that is in DATA.bib to the data folder (from "initial/data") - so basically can be run once in the end, depends. Existing data will not be overwritten but skipped - so if you need to update the data, remove the files from the data folder first!
#create a folder with two dummy datasets (empty xlsx files)
dir.create("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example/bootstrap/initial/data/collection/")
file.create("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example/bootstrap/initial/data/collection/1.csv")
invisible(file.create("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example/bootstrap/initial/data/collection/2.csv"))
setwd("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example")
#install.packages("icesTAF")
library(icesTAF)
#creates folder structure
taf.skeleton()
###############-----------1. create metadata----------################### (.bib file)
# create metadata
draft.data(
data.files = "trees.csv",
data.scripts = NULL,
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 # create a new DATA.bib
)
# create metadata (add to previous BATA.bib)
draft.data(
data.files = "HadSST.4.0.1.0_median.nc", #can be a folder with multiple files
originator = "UK MET office",
data.scripts = NULL,
title = "Met office observations data set",
source = "https://www.metoffice.gov.uk/hadobs/hadsst4/data/netcdf/HadSST.4.0.1.0_median.nc",
year = 2022,
file = TRUE,
append = TRUE # append to existing DATA.bib
)
draft.data(
data.files = "collection", #give name of a folder
originator = "myself",
data.scripts = NULL,
title = "empty sheets",
source = "folder", #write folder if it is a folder
year = 2022,
file = TRUE,
append = TRUE # append to existing DATA.bib
)
#bring in data from script
draft.data(
data.files = NULL,
data.scripts = "ices-areas.R", # this needs to be in the bootstrap folder
originator = "ICES",
title = "ICES areas",
file = TRUE,
append = TRUE
)
##################----------------bring in initial data/scripts----------------#########################
#bring in a local file from elsewhere (to initial/data)
cp("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/sample_files/trees.csv", "bootstrap/initial/data/")
#download data
download("https://www.metoffice.gov.uk/hadobs/hadsst4/data/netcdf/HadSST.4.0.1.0_median.nc", dir = "C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example/bootstrap/initial/data")
#create a folder with two dummy datasets (empty xlsx files)
dir.create("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example/bootstrap/initial/data/collection/")
invisible(file.create("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example/bootstrap/initial/data/collection/1.csv"))
invisible(file.create("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example/bootstrap/initial/data/collection/2.csv"))
#copy script to bootstrap
invisible(file.copy("C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/sample_files/ices-areas.R", "C:/Users/pohlmann/Desktop/Home_Office/Projekte/wg_WGEEL/Misc/WKTAF/Example/bootstrap/ices-areas.R"))
##################----------------copy initial data to actual data folder (basically a copy to work with----------------#########################
taf.bootstrap(software = FALSE) #brings all data that is in DATA.bib to the data folder (from "initial/data") - so basically can be run once in the end, depends. Existing data will not be overwritten but skipped - so if you need to update the data, remove the files from the data folder first!
35 changes: 35 additions & 0 deletions Misc/WKTAF/Example/bootstrap/DATA.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@Misc{trees.csv,
originator = {Ryan, T. A., Joiner, B. L. and Ryan, B. F. (1976) The Minitab Student Handbook. Duxbury Press.},
year = {2022},
title = {Diameter, Height and Volume for Black Cherry Trees},
period = {},
access = {Public},
source = {file},
}

@Misc{HadSST.4.0.1.0_median.nc,
originator = {UK MET office},
year = {2022},
title = {Met office observations data set},
period = {},
access = {Public},
source = {https://www.metoffice.gov.uk/hadobs/hadsst4/data/netcdf/HadSST.4.0.1.0_median.nc},
}

@Misc{collection,
originator = {myself},
year = {2022},
title = {empty sheets},
period = {},
access = {Public},
source = {folder},
}

@Misc{ices-areas,
originator = {ICES},
year = {2022},
title = {ICES areas},
period = {},
access = {Public},
source = {script},
}
Binary file not shown.
Empty file.
Empty file.
62 changes: 62 additions & 0 deletions Misc/WKTAF/Example/bootstrap/data/ices-areas/DISCLAIMER_GIS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
1. IMPORTANT

Thank you for downloading data from the International Council for the Exploration of the Sea (ICES).

By downloading data from the ICES website and sub-domains [ices.dk] you are agreeing to the terms and conditions of use as described in this document and any documents referred to in this text.

Please read this before using the downloaded data, as this file contains specific information about the use of the data provided, limitations, and known issues. This file contains contact information regarding the origins of the data (where supplied) as well as how to cite these data in a publication or a data product.


2. CONTACT INFORMATION

For feedback or queries about this data download, contact ICES at:
Email: [email protected]
Tel.: +45 3338 6700
Find more information at:
Web: https://www.ices.dk/data/Pages/default.aspx


3. DATA SPECIFIC INFORMATION

ICES Spatial datasets are freely available for download from https://gis.ices.dk

4. TERMS OF USE: DATA

ICES makes data available to users in an open, timely and easy way, but ICES remains dependent on data contributions.
- Correct and appropriate data interpretation is solely the responsibility of data users.
- Data Users must not expressly or otherwise imply ICES substantiation of their work, results, conclusions and/or recommendations.
- Data sources must be duly acknowledged.
- Data Users must respect any and all restrictions on the use or reproduction of data such as restrictions on use for commercial purposes.
- Data Users are obliged to inform ICES of any suspected problems in the data.
- Data Users are encouraged to inform ICES of possible sources of other relevant data.
The full ICES data policy and terms of use can be viewed at:
https://ices.dk/data/guidelines-and-policy/Pages/ICES-data-policy.aspx.
Data held at ICES are used for various assessments and working group purposes. The data guidelines and procedures for these can be viewed at:
https://ices.dk/data/guidelines-and-policy/Pages/default.aspx


5. TERMS OF USE: SOFTWARE

Software is available for use from the ICES website that is provided as an aid for data users to work with, analyse and convert data:
https://ices.dk/data/tools/Pages/Software.aspx
The downloading and use of any software from https://www.ices.dk/ grants you only a limited, nonexclusive license for use solely by you for your own personal use and not for republication, distribution, assignment, sublicense, sale or other use. No part of any content, coding or documentation may be reproduced in any form or incorporated into any information retrieval system without the express permission of ICES or the third party that provided the software on https://www.ices.dk/
The downloading and installation of software from https://www.ices.dk/ is at your own risk. ICES undertakes every effort to ensure software is compatible with the latest windows operating system, or other systems as defined in specific readme or a software documentation file. ICES accepts no responsibility for the correct functioning and operation of software downloaded from https://www.ices.dk/, nor any incidental, special or consequential damages associated with downloading and installing software provided by ICES.


6. DATA CITATION

Data sources should be acknowledged by a citation. Detailed information and examples of citations can be found in ICES Data Policy: https://ices.dk/data/guidelines-and-policy/Pages/ICES-data-policy.aspx.

A minimum requirement citation would include the following:
�ICES Spatial Facility, ICES, Copenhagen.�


7. METADATA

Further details about the dataset and related services can be found at the metadata catalogue.

ICES Datasets: https://gis.ices.dk/geonetwork/srv/eng/catalog.search#/search?facet.q=type%2Fdataset%26orgName%2FICES

Services: https://gis.ices.dk/geonetwork/srv/eng/catalog.search#/search?facet.q=type%2Fservice


67 changes: 67 additions & 0 deletions Misc/WKTAF/Example/bootstrap/data/ices-areas/ices-areas.csv

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions Misc/WKTAF/Example/bootstrap/data/trees.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"","Girth","Height","Volume"
"1",8.3,70,10.3
"2",8.6,65,10.3
"3",8.8,63,10.2
"4",10.5,72,16.4
"5",10.7,81,18.8
"6",10.8,83,19.7
"7",11,66,15.6
"8",11,75,18.2
"9",11.1,80,22.6
"10",11.2,75,19.9
"11",11.3,79,24.2
"12",11.4,76,21
"13",11.4,76,21.4
"14",11.7,69,21.3
"15",12,75,19.1
"16",12.9,74,22.2
"17",12.9,85,33.8
"18",13.3,86,27.4
"19",13.7,71,25.7
"20",13.8,64,24.9
"21",14,78,34.5
"22",14.2,80,31.7
"23",14.5,74,36.3
"24",16,72,38.3
"25",16.3,77,42.6
"26",17.3,81,55.4
"27",17.5,82,55.7
"28",17.9,80,58.3
"29",18,80,51.5
"30",18,80,51
"31",20.6,87,77
18 changes: 18 additions & 0 deletions Misc/WKTAF/Example/bootstrap/ices-areas.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
library(icesTAF)
library(sf)
download(
"http://gis.ices.dk/shapefiles/ICES_areas.zip"
)

unzip("ICES_areas.zip")
unlink("ICES_areas.zip")

areas <- st_read("ICES_Areas_20160601_cut_dense_3857.shp")

# write as csv
st_write(
areas, "ices-areas.csv",
layer_options = "GEOMETRY=AS_WKT"
)

unlink(dir(pattern = "ICES_Areas_20160601_cut_dense_3857"))
Binary file not shown.
Empty file.
Empty file.
32 changes: 32 additions & 0 deletions Misc/WKTAF/Example/bootstrap/initial/data/trees.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"","Girth","Height","Volume"
"1",8.3,70,10.3
"2",8.6,65,10.3
"3",8.8,63,10.2
"4",10.5,72,16.4
"5",10.7,81,18.8
"6",10.8,83,19.7
"7",11,66,15.6
"8",11,75,18.2
"9",11.1,80,22.6
"10",11.2,75,19.9
"11",11.3,79,24.2
"12",11.4,76,21
"13",11.4,76,21.4
"14",11.7,69,21.3
"15",12,75,19.1
"16",12.9,74,22.2
"17",12.9,85,33.8
"18",13.3,86,27.4
"19",13.7,71,25.7
"20",13.8,64,24.9
"21",14,78,34.5
"22",14.2,80,31.7
"23",14.5,74,36.3
"24",16,72,38.3
"25",16.3,77,42.6
"26",17.3,81,55.4
"27",17.5,82,55.7
"28",17.9,80,58.3
"29",18,80,51.5
"30",18,80,51
"31",20.6,87,77
9 changes: 9 additions & 0 deletions Misc/WKTAF/Example/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Preprocess data, write TAF data tables

## Before:
## After:

library(icesTAF)

mkdir("data")

Loading

0 comments on commit 6bf0161

Please sign in to comment.