-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02_agriwanet.R
130 lines (113 loc) · 4.33 KB
/
02_agriwanet.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
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
128
129
130
# ----
# title : build census database - agriwanet
# description : this script integrates data of 'agriwanet' (https://doi.org/10.7802/2008)
# license : https://creativecommons.org/licenses/by-sa/4.0/
# authors : Steffen Ehrmann
# date : 2024-06-05
# version : 1.0.0
# status : done
# comment : -
# ----
# geography : Central Asia
# spatial : Nation, Oblast
# period : 1992 - 2015
# variables :
# - land : -
# - crops : hectares_harvested, tons_produced
# - livestock : number_heads
# - tech : -
# - social : -
# sampling : survey
# ----
ds <- c("agriwanet")
gs <- c("gadm")
# 1. dataseries ----
#
regDataseries(name = ds[1],
description = "Agricultural Restructuring, Water Scarcity and the Adaptation to Climate Change in Central Asia",
homepage = "https://doi.org/10.7802/2008",
version = "",
licence_link = "CC BY 4.0")
# 2. geometries ----
#
# based on GADM 3.6
# 3. census tables ----
#
## crops ----
if(build_crops){
schema_agriwanet1 <-
setIDVar(name = "ADM0", columns = 1) %>%
setIDVar(name = "ADM1", columns = 2) %>%
setIDVar(name = "year", columns = 4) %>%
setIDVar(name = "method", value = "yearbook") %>%
setIDVar(name = "crop", columns = c(20:34), rows = 1) %>%
setObsVar(name = "hectares_harvested", factor = 1000, columns = c(20:34),
key = 3, value = "all farms (not applic case) (10)")
regTable(subset = "harvested",
label = "ADM1",
dSeries = ds[1],
gSeries = gs[1],
schema = schema_agriwanet1,
begin = 1992,
end = 2015,
archive = "agriwanet_data_en_V1.0.csv",
archiveLink = "https://data.gesis.org/sharing/#!Detail/10.7802/2008",
updateFrequency = "unknown",
downloadDate = ymd("2019-10-10"),
metadataLink = "https://data.gesis.org/sharing/#!Detail/10.7802/2008",
metadataPath = "agriwanet_codebook_en.pdf",
overwrite = TRUE)
schema_agriwanet2 <-
setIDVar(name = "ADM0", columns = 1) %>%
setIDVar(name = "ADM1", columns = 2) %>%
setIDVar(name = "year", columns = 4) %>%
setIDVar(name = "method", value = "yearbook") %>%
setIDVar(name = "crop", columns = c(35:49), rows = 1) %>%
setObsVar(name = "tons_produced", factor = 1000, columns = c(35:49),
key = 3, value = "all farms (not applic case) (10)")
regTable(subset = "production",
label = "ADM1",
dSeries = ds[1],
gSeries = gs[1],
schema = schema_agriwanet2,
begin = 1992,
end = 2015,
archive = "agriwanet_data_en_V1.0.csv",
archiveLink = "https://data.gesis.org/sharing/#!Detail/10.7802/2008",
updateFrequency = "unknown",
downloadDate = ymd("2019-10-10"),
metadataLink = "https://data.gesis.org/sharing/#!Detail/10.7802/2008",
metadataPath = "agriwanet_codebook_en.pdf",
overwrite = TRUE)
normTable(pattern = ds[1],
ontoMatch = "crop",
beep = 10)
}
## livestock ----
if(build_livestock){
schema_agriwanet3 <-
setIDVar(name = "ADM0", columns = 1) %>%
setIDVar(name = "ADM1", columns = 2) %>%
setIDVar(name = "year", columns = 4) %>%
setIDVar(name = "method", value = "yearbook") %>%
setIDVar(name = "animal", columns = c(50:53), rows = 1) %>%
setObsVar(name = "number_heads", factor = 1000, columns = c(50:53),
key = 3, value = "all farms (not applic case) (10)")
regTable(subset = "livestock",
label = "ADM1",
dSeries = ds[1],
gSeries = gs[1],
schema = schema_agriwanet3,
begin = 1992,
end = 2015,
archive = "agriwanet_data_en_V1.0.csv",
archiveLink = "https://data.gesis.org/sharing/#!Detail/10.7802/2008",
updateFrequency = "unknown",
downloadDate = ymd("2019-10-10"),
metadataLink = "https://data.gesis.org/sharing/#!Detail/10.7802/2008",
metadataPath = "agriwanet_codebook_en.pdf",
overwrite = TRUE)
normTable(pattern = paste0("livestock.*", ds[1]),
ontoMatch = "animal",
beep = 10)
}