-
Notifications
You must be signed in to change notification settings - Fork 1
/
V2-ab-line.Rmd
116 lines (94 loc) · 4.65 KB
/
V2-ab-line.Rmd
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
---
title: "Trial AB-line Types and Options"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Trial AB-line Types and Options}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.height = 6
)
```
Load the `ofpetrial` package
```{r setup}
library(ofpetrial)
library(ggplot2)
```
AB-line is the driving direction of a machine. In practice, a farmer uploads AB-lines into the machine and can choose between these AB-lines at the time of operation. While this AB-line indicates the driving direction of the machine, it can also be used to center the machine on this line. Centering the machine on the AB-line becomes important when conducting OFPEs.
The function `make_input_plot_data` contains several options for `abline_type`: "free", "lock", and "none". When `abline_type = "lock"`, the resulting experimental plots will be centered on the initial AB-line given by `abline_data`, and the AB-line returned by the `write_trial_files` function will be identical to that in `abline_data`. If `abline_type` equals "free", the experimental plots are also centered on the AB-line, but the AB-lines returned by the `write_trial_files` function are created to be in the first and last rows of the experimental plot. Then the farmer can choose the side where they prefer to start. Generally, the "free" option is best unless there is a reason the farmer or operator needs to start in a specific part of the field. Finally, the "none" option is similar to lock but it will not return a new AB-line for the trial, assuming that the line in `abline_data` will be used.
The following example uses a seeding trial to demonstrate the three options for `abline_type`. When visualizing the trial plots and AB-line with `viz_layout`, the differences between these options are clearer as the AB-line shifts or is not included.
```{r ab-line-example1}
input_plot_info <-
prep_plot(
input_name = "seed",
unit_system = "imperial",
machine_width = 60,
section_num = 24,
harvester_width = 30,
plot_width = 60
)
exp_plots_free <-
make_exp_plots(
input_plot_info = input_plot_info,
boundary_data = system.file("extdata", "boundary-simple1.shp", package = "ofpetrial"),
abline_data = system.file("extdata", "ab-line-simple1.shp", package = "ofpetrial"),
abline_type = "free"
)
viz(exp_plots_free, type = "layout", abline = TRUE)
```
```{r ab-line-example2}
exp_plots_lock <-
make_exp_plots(
input_plot_info = input_plot_info,
boundary_data = system.file("extdata", "boundary-simple1.shp", package = "ofpetrial"),
abline_data = system.file("extdata", "ab-line-simple1.shp", package = "ofpetrial"),
abline_type = "lock"
)
viz(exp_plots_lock, type = "layout", abline = TRUE)
```
```{r ab-line-example3}
exp_plots_none <-
make_exp_plots(
input_plot_info = input_plot_info,
boundary_data = system.file("extdata", "boundary-simple1.shp", package = "ofpetrial"),
abline_data = system.file("extdata", "ab-line-simple1.shp", package = "ofpetrial"),
abline_type = "none"
)
exp_plots_none$ab_lines
```
There are also different ways to create an initial AB-line. If there is an existing AB-line shapefile, then include the pathway to this file in `abline_data`. If there is a past as-applied, as-planted or yield shapefile, the trial can also be centered on the paths from that previous operation. This pathway is included in ???. Using the points in the past file, an AB-line will be created. As the initial file AB-line has no specific AB-line location, the `abline_type` is "free".
The sample data `as-applied-simple1.shp` is a soybean planting map from a trial with a 60-foot planter We can use this data to create an AB-line for a new soybean trial with the same equipment.
```{r plot-yield-data}
aa <- system.file("extdata", "as-applied-simple1.shp", package = "ofpetrial") %>%
sf::st_read()
plot(aa$geometry, pch = 1, cex = .1)
```
```{r ab-line-from-yield}
input_plot_info <-
prep_plot(
input_name = "seed",
unit_system = "imperial",
machine_width = 60,
section_num = 1,
harvester_width = 60,
plot_width = 60
)
exp_plots_aa <-
make_exp_plots(
input_plot_info = input_plot_info,
boundary_data = system.file("extdata", "boundary-simple1.shp", package = "ofpetrial"),
abline_data = system.file("extdata", "as-applied-simple1.shp", package = "ofpetrial"),
abline_type = "lock"
)
viz(exp_plots_aa, type = "layout", abline = TRUE)
```
```{r view-results-from-yield}
ggplot() +
geom_sf(data = exp_plots_aa$exp_plots[[1]], fill = NA) +
geom_sf(data = aa, color = "blue", size = 0.25) +
theme_void()
```