-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_denmark.R
More file actions
126 lines (107 loc) · 3.67 KB
/
03_denmark.R
File metadata and controls
126 lines (107 loc) · 3.67 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
# ----
# title : build census database - dstdk
# description : this script integrates data of 'Statistics Denmark' (https://www.statbank.dk, https://www.statbank.dk/statbank5a)
# license : https://creativecommons.org/licenses/by-sa/4.0/
# authors : Steffen Ehrmann
# date : 2024-09-27
# version : 0.0.1
# status : work in progress
# comment : file.edit(paste0(dir_docs, "/documentation/mdl_build_census_database.md"))
# ----
# geography : Denmark
# spatial : _INSERT
# period : _INSERT
# variables :
# - land : hectares_covered
# - crops : hectares_planted, hectares_harvested, tons_produced, kiloPerHectare_yield
# - livestock : number_heads, colonies
# - tech : number_machines, tons_applied (fertilizer)
# - social : _INSERT
# sampling : survey, census
# ----
thisNation <- "Denmark"
# 1. dataseries ----
#
ds <- c("dstdk")
gs <- c("gadm")
regDataseries(name = ds[1],
description = "Statistics Denmark",
homepage = "https://www.statbank.dk",
version = "2024.10",
licence_link = "unknown")
# 2. geometries ----
#
# 3. tables ----
#
if(build_crops){
## crops ----
# https://www.statbank.dk/AFG5
# https://www.statbank.dk/AFG
#
# https://www.statbank.dk/HST77
# https://www.statbank.dk/HST7
# https://www.statbank.dk/HALM
# https://www.statbank.dk/HALM1
# https://www.statbank.dk/FL1
# work in progress
}
if(build_livestock){
## livestock ----
schema_livestock <-
setFormat() %>%
setIDVar(name = "ADM1", ) %>%
setIDVar(name = "year", ) %>%
setIDVar(name = "method", value = "") %>%
setIDVar(name = "animal", ) %>%
setObsVar(name = "number_heads", )
regTable(ADM0 = !!thisNation,
label = "ADM1",
subset = "livestock",
dSeries = ds[1],
gSeries = gs[1],
schema = schema_default,
begin = 1982,
end = 2006,
archive = "2025116204311516975717HDYR74683155415.csv",
archiveLink = "https://www.statbank.dk/HDYR",
downloadDate = ymd("2025-01-16"),
updateFrequency = "annually",
metadataLink = "https://www.statbank.dk/statbank5a/selectvarval/Define.asp?MainTable=HDYR&TabStrip=Info&PLanguage=1&FF=8",
metadataPath = "unknown",
overwrite = TRUE)
regTable(ADM0 = !!thisNation,
label = "ADM1",
subset = "livestock",
dSeries = ds[1],
gSeries = gs[1],
schema = schema_livestock,
begin = 2006,
end = 2023,
archive = "2025125195843518822102HDYR0771926996370.csv",
archiveLink = "https://www.statbank.dk/HDYR07",
downloadDate = ymd("2025-01-16"),
updateFrequency = "annually",
metadataLink = "https://www.statbank.dk/statbank5a/selectvarval/Define.asp?MainTable=HDYR07&TabStrip=Info&PLanguage=1&FF=8",
metadataPath = "unknown",
overwrite = TRUE)
normTable(pattern = ds[1],
ontoMatch = "animal",
beep = 10)
}
if(build_landuse){
## landuse ----
# work in progress
}
#### test schemas
#
myRoot <- paste0(dir_census_wip, "tables/stage2/")
myFile <- ""
input <- read_csv(file = paste0(myRoot, myFile),
col_names = FALSE,
col_types = cols(.default = "c"))
schema <- schema_nbs_livestock
validateSchema(schema = schema, input = input)
output <- reorganise(input = input, schema = schema)
#
# https://github.com/luckinet/tabshiftr/issues
#### delete this section after finalising script