Skip to contents

Function providing loading for data templates (with single and multiple data sheets) (data should have been cleaned before).

Usage

load_template(template_path, epsg_code = 4326)

Arguments

template_path

path to *.xlsx file.

epsg_code

EPSG code for station coordinates (default 4326 for WGS 84 coordinate system) system

Value

list of two: stations dataframe, which contains station information, second member of list contains contains measurement data in dataframe (if data is in one sheet) or nested list of dataframes with each parameter in separate dataframe.

Examples

##Two types of templates could be used
# 1) Example of template for weather data
temp_path <- system.file("extdata", "weather_data.xlsx", package = "svatools")
met_lst <- load_template(temp_path, 3035)
#> [1] "Loading data from template."
#> [1] "Reading station ID9 data."
#> [1] "Reading station ID3 data."
#> [1] "Reading station ID10 data."
#> [1] "Reading station ID11 data."
#> [1] "Reading station ID12 data."
#> [1] "Reading station ID13 data."
#> [1] "Reading station ID1 data."
#> [1] "Reading station ID8 data."
#> [1] "Reading station ID2 data."
#> [1] "Reading station ID4 data."
#> [1] "Reading station ID5 data."
#> [1] "Reading station ID6 data."
#> [1] "Reading station ID7 data."
#> [1] "Reading station ID14 data."
#> [1] "Loading of data is finished."
str(met_lst)
#> List of 2
#>  $ stations: sf [14 × 7] (S3: sf/tbl_df/tbl/data.frame)
#>   ..$ ID       : chr [1:14] "ID1" "ID2" "ID3" "ID4" ...
#>   ..$ Name     : chr [1:14] "RUDZK DUZY" "GLEBOKIE" "GLODOWO" "SOBIESIERNIE" ...
#>   ..$ Elevation: chr [1:14] "98.7" "85.0" "99.0" "80.0" ...
#>   ..$ Source   : chr [1:14] "ODR" "IMGW" "IMGW" "IMGW" ...
#>   ..$ geometry :sfc_POINT of length 14; first list element:  'XY' num [1:2] 4892472 3300305
#>   ..$ Long     : num [1:14] 4892472 4891414 4941373 4890114 4899376 ...
#>   ..$ Lat      : num [1:14] 3300305 3315522 3342216 3326585 3286548 ...
#>   ..- attr(*, "sf_column")= chr "geometry"
#>   ..- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA
#>   .. ..- attr(*, "names")= chr [1:6] "ID" "Name" "Elevation" "Source" ...
#>  $ data    :List of 14
#>   ..$ ID9 :List of 6
#>   .. ..$ SLR    : tibble [2,952 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:2952], format: "2014-01-01" ...
#>   .. .. ..$ SLR : num [1:2952] 1.32 2.83 2.73 2.08 2.25 ...
#>   .. ..$ RELHUM : tibble [3,317 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:3317], format: "2014-01-01" ...
#>   .. .. ..$ RELHUM: num [1:3317] 0.885 0.873 0.881 0.887 0.888 ...
#>   .. ..$ TMP_MAX: tibble [3,317 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:3317], format: "2014-01-01" ...
#>   .. .. ..$ TMP_MAX: num [1:3317] 3.4 4.2 6.4 6.6 9.3 7.2 9.6 9.3 9.6 9.4 ...
#>   .. ..$ TMP_MIN: tibble [3,306 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:3306], format: "2014-01-01" ...
#>   .. .. ..$ TMP_MIN: num [1:3306] 0.4 -1.6 0.3 2.4 4.1 1.4 4.2 4.4 3.1 5.1 ...
#>   .. ..$ PCP    : tibble [3,197 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:3197], format: "2014-05-01" ...
#>   .. .. ..$ PCP : num [1:3197] 0 1 0 0.2 0 0.2 1 0 0.8 0.2 ...
#>   .. ..$ WNDSPD : tibble [760 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:760], format: "2021-01-01" ...
#>   .. .. ..$ WNDSPD: num [1:760] 1.89 1.1 2.68 2.36 1.85 ...
#>   ..$ ID3 :List of 3
#>   .. ..$ TMP_MAX: tibble [6,726 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:6726], format: "1998-01-01" ...
#>   .. .. ..$ TMP_MAX: num [1:6726] 6.6 4.4 7.5 6.2 6.6 6.2 5 7 4.6 3.5 ...
#>   .. ..$ TMP_MIN: tibble [6,726 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:6726], format: "1998-01-01" ...
#>   .. .. ..$ TMP_MIN: num [1:6726] 1 1.6 1.5 3.3 2.5 2.5 2.8 3.5 1.6 1.1 ...
#>   .. ..$ RELHUM : tibble [1,154 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:1154], format: "1998-01-01" ...
#>   .. .. ..$ RELHUM: num [1:1154] 0.91 0.903 0.86 0.828 0.823 0.92 0.923 0.895 0.943 0.96 ...
#>   ..$ ID10:List of 4
#>   .. ..$ TMP_MAX: tibble [1,948 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:1948], format: "2016-06-01" ...
#>   .. .. ..$ TMP_MAX: num [1:1948] 25.3 23.8 23.5 26 23.6 19 21.4 26.7 20 21.3 ...
#>   .. ..$ TMP_MIN: tibble [1,948 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:1948], format: "2016-06-01" ...
#>   .. .. ..$ TMP_MIN: num [1:1948] 14.3 14.5 13 11.8 10.7 8.9 6.1 8 10.1 8.5 ...
#>   .. ..$ RELHUM : tibble [1,947 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:1947], format: "2016-06-01" ...
#>   .. .. ..$ RELHUM: num [1:1947] 0.787 0.806 0.646 0.646 0.551 0.541 0.486 0.546 0.601 0.62 ...
#>   .. ..$ WNDSPD : tibble [1,932 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:1932], format: "2016-06-01" ...
#>   .. .. ..$ WNDSPD: num [1:1932] 3.4 3.2 3.6 1.5 3.1 3.4 1.6 2.6 2.3 4 ...
#>   ..$ ID11:List of 3
#>   .. ..$ SLR   : tibble [6,940 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:6940], format: "2000-01-01" ...
#>   .. .. ..$ SLR : num [1:6940] 1.16 0.85 0.77 0.55 0.82 1.02 0.77 2.72 0.54 0.99 ...
#>   .. ..$ MAXHHR: tibble [4,040 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:4040], format: "2008-06-06" ...
#>   .. .. ..$ MAXHHR: num [1:4040] 0 0 0 0 0 0 0 0.9 0.1 0.2 ...
#>   .. ..$ PCP   : tibble [4,040 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:4040], format: "2008-06-06" ...
#>   .. .. ..$ PCP : num [1:4040] 0 0 0 0 0 0 0 2.8 0.1 0.3 ...
#>   ..$ ID12:List of 6
#>   .. ..$ TMP_MAX: tibble [8,571 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:8571], format: "1998-01-01" ...
#>   .. .. ..$ TMP_MAX: num [1:8571] 6.8 4.7 8.1 6.6 7.4 5.6 6.6 8.1 5.5 6 ...
#>   .. ..$ TMP_MIN: tibble [8,571 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:8571], format: "1998-01-01" ...
#>   .. .. ..$ TMP_MIN: num [1:8571] 1.1 0.4 1.1 3.2 1.6 2.2 2.7 4.7 1.7 1.7 ...
#>   .. ..$ RELHUM : tibble [6,574 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:6574], format: "1998-01-01" ...
#>   .. .. ..$ RELHUM: num [1:6574] 0.903 0.94 0.83 0.825 0.755 0.908 0.935 0.9 0.975 0.983 ...
#>   .. ..$ WNDSPD : tibble [6,574 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:6574], format: "1998-01-01" ...
#>   .. .. ..$ WNDSPD: num [1:6574] 2 1.7 3.7 4.3 7.3 3.7 3 5 2 1.7 ...
#>   .. ..$ MAXHHR : tibble [3,187 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:3187], format: "2012-06-13" ...
#>   .. .. ..$ MAXHHR: num [1:3187] 6.6 8.5 0.2 3.8 4.4 0.1 0 9.9 2.9 0.5 ...
#>   .. ..$ PCP    : tibble [3,187 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:3187], format: "2012-06-13" ...
#>   .. .. ..$ PCP : num [1:3187] 13 21.3 0.3 10.9 7.8 0.1 0 34.1 21.1 0.9 ...
#>   ..$ ID13:List of 5
#>   .. ..$ TMP_MAX: tibble [8,379 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:8379], format: "1998-01-01" ...
#>   .. .. ..$ TMP_MAX: num [1:8379] 7.5 5.5 8.7 7.2 8.5 5.7 6.4 9 5.8 4.8 ...
#>   .. ..$ TMP_MIN: tibble [8,380 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:8380], format: "1998-01-01" ...
#>   .. .. ..$ TMP_MIN: num [1:8380] 1.1 0.5 1.5 3.5 2.2 2.7 2.7 4.5 2.6 1.9 ...
#>   .. ..$ SLR    : tibble [6,915 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:6915], format: "2000-01-01" ...
#>   .. .. ..$ SLR : num [1:6915] 1.45 0.97 0.55 0.31 1.15 0.96 0.71 2.6 2.52 1.06 ...
#>   .. ..$ RELHUM : tibble [8,358 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:8358], format: "1998-01-01" ...
#>   .. .. ..$ RELHUM: num [1:8358] 0.949 0.923 0.826 0.809 0.706 0.928 0.911 0.873 0.973 0.994 ...
#>   .. ..$ WNDSPD : tibble [8,401 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:8401], format: "1998-01-01" ...
#>   .. .. ..$ WNDSPD: num [1:8401] 2.5 3.5 4.9 5.5 7.5 6.4 5.1 6.5 2.5 2 ...
#>   ..$ ID1 :List of 5
#>   .. ..$ TMP_MAX: tibble [930 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:930], format: "2018-10-27" ...
#>   .. .. ..$ TMP_MAX: num [1:930] 11.2 7.9 10.1 19.6 15.4 ...
#>   .. ..$ TMP_MIN: tibble [868 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:868], format: "2018-10-27" ...
#>   .. .. ..$ TMP_MIN: num [1:868] 4.67 0.64 1.8 10.09 4.57 ...
#>   .. ..$ RELHUM : tibble [565 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:565], format: "2018-10-27" ...
#>   .. .. ..$ RELHUM: num [1:565] 0.716 0.877 0.983 0.81 0.712 ...
#>   .. ..$ WNDSPD : tibble [930 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:930], format: "2018-10-27" ...
#>   .. .. ..$ WNDSPD: num [1:930] 1.09 1.47 3.04 2.97 1 ...
#>   .. ..$ PCP    : tibble [384 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:384], format: "2019-01-01" ...
#>   .. .. ..$ PCP : num [1:384] 4.3 1.1 1.8 2.5 5.9 1.2 0.7 1.5 3.3 0.1 ...
#>   ..$ ID8 :List of 4
#>   .. ..$ TMP_MAX: tibble [1,171 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:1171], format: "2018-01-01" ...
#>   .. .. ..$ TMP_MAX: num [1:1171] 9.68 3.79 4.13 7.41 7.63 7.54 4.05 1.45 2.14 1.27 ...
#>   .. ..$ TMP_MIN: tibble [1,165 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE   : POSIXct[1:1165], format: "2018-01-01" ...
#>   .. .. ..$ TMP_MIN: num [1:1165] 2.59 0.36 0.21 3.95 3.47 2 -2.74 -6.5 -4.29 -0.33 ...
#>   .. ..$ RELHUM : tibble [1,171 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:1171], format: "2018-01-01" ...
#>   .. .. ..$ RELHUM: num [1:1171] 0.875 0.969 0.974 0.897 0.903 ...
#>   .. ..$ PCP    : tibble [402 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:402], format: "2018-04-01" ...
#>   .. .. ..$ PCP : num [1:402] 6.8 1.6 7 8.4 3.6 4.2 0.6 2.4 27.2 0.2 ...
#>   ..$ ID2 :List of 1
#>   .. ..$ PCP: tibble [8,673 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:8673], format: "1998-01-01" ...
#>   .. .. ..$ PCP : num [1:8673] 0 0 0 0 0 0 0 0 0 0 ...
#>   ..$ ID4 :List of 1
#>   .. ..$ PCP: tibble [8,673 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:8673], format: "1998-01-01" ...
#>   .. .. ..$ PCP : num [1:8673] 0 0 2.2 0 3.5 1.3 9.2 6.3 0.4 0 ...
#>   ..$ ID5 :List of 1
#>   .. ..$ PCP: tibble [8,673 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:8673], format: "1998-01-01" ...
#>   .. .. ..$ PCP : num [1:8673] 0 0 2.1 0.3 4.7 0.8 2.5 13.5 0.6 0.7 ...
#>   ..$ ID6 :List of 1
#>   .. ..$ PCP: tibble [8,673 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:8673], format: "1998-01-01" ...
#>   .. .. ..$ PCP : num [1:8673] 0.5 0 2.2 0 3.6 1.2 3.2 7 0 0 ...
#>   ..$ ID7 :List of 1
#>   .. ..$ PCP: tibble [8,673 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:8673], format: "1998-01-01" ...
#>   .. .. ..$ PCP : num [1:8673] 0 0 2.8 0.3 3.1 2.1 1.5 11.6 1 0.2 ...
#>   ..$ ID14:List of 2
#>   .. ..$ SLR   : tibble [365 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE: POSIXct[1:365], format: "2022-01-01" ...
#>   .. .. ..$ SLR : num [1:365] 0.683 0.798 0.671 1.203 1.064 ...
#>   .. ..$ RELHUM: tibble [365 × 2] (S3: tbl_df/tbl/data.frame)
#>   .. .. ..$ DATE  : POSIXct[1:365], format: "2022-01-01" ...
#>   .. .. ..$ RELHUM: num [1:365] 1 1 1 1 1 1 1 1 1 1 ...
## 2) Example of template for calibration data
temp_path <- system.file("extdata", "calibration_data.xlsx", package = "svatools")
cal_data <- load_template(temp_path)
#> [1] "Loading data from template."
#> [1] "Loading of data is finished."
str(cal_data)
#> List of 2
#>  $ stations: sf [20 × 6] (S3: sf/tbl_df/tbl/data.frame)
#>   ..$ ID         : chr [1:20] "5" "8" "4" "2" ...
#>   ..$ Name       : chr [1:20] "Zgłowiączka-Strózewo-Parcele" "DopZStarRadziejewa - Witowo" "Zgłąwiączka-ponizej. Osiecin,Samszyce" "Zgłowiączka-pow.Osiecin. Piołunowo" ...
#>   ..$ Description: chr [1:20] "powyżej jez. Głuszyńskiego (60 km)" "Kolonia Witowo" "Samszyce - poniżej Osięcin (67,8 km)" "powyżej Osięcin (75,2 km)" ...
#>   ..$ geometry   :sfc_POINT of length 20; first list element:  'XY' num [1:2] 18.7 52.6
#>   ..$ Long       : num [1:20] 18.7 18.7 18.7 18.7 18.7 ...
#>   ..$ Lat        : num [1:20] 52.6 52.6 52.6 52.6 52.6 ...
#>   ..- attr(*, "sf_column")= chr "geometry"
#>   ..- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA
#>   .. ..- attr(*, "names")= chr [1:5] "ID" "Name" "Description" "Long" ...
#>  $ data    : tibble [22,306 × 5] (S3: tbl_df/tbl/data.frame)
#>   ..$ Station  : chr [1:22306] "1" "1" "1" "1" ...
#>   ..$ DATE     : POSIXct[1:22306], format: "2008-03-11" "2008-03-25" ...
#>   ..$ Variables: chr [1:22306] "N-NH4" "N-NH4" "N-NH4" "N-NH4" ...
#>   ..$ Values   : num [1:22306] 0.05 0.05 0.05 0.05 0.05 0.05 0.83 0.25 0.51 1.89 ...
#>   ..$ Source   : chr [1:22306] "grab sample" "grab sample" "grab sample" "grab sample" ...