Description Usage Arguments Value Author(s) Examples
View source: R/apply_texture.R
A set of functions is stored in the package. These functions represent specific patterns for each horizon and are named according to the horizons. Pay attention! don't write functions with the names that already exist in R for example "C".
df_par_wide is a tibble with the graphical parameters in wide format (saved in the sys.data). The key to join the tables is the "name" column and the "par_Id" column. The "par_Id" column starts with one for the background layer and then ascends to the top layer. An example tibble, which can be extended with the function save_par_setting, is stored in the package (sysdata.rda)
The actual task is to link the horizon rows to the corresponding functions and then apply these functions
If a horizonname do not matched it will be used the random_line_pattern function. If the information about the soil texture is available, the texture function fun_grain_size is preferred.
1 2 | apply_texture(shape, buffer = -1, dist_size = 1,
background = "random")
|
shape |
A simple features file with one row for each hoizon. At least with one geometry column and one "nameC" column ("C" for character). The variables clay silt and sand are optional and will be specified in the respective proportions. The sum must be one. if at least one value isn't zero, a point grid is created for the texture. With the function par_dafault the grain size can be changed. |
buffer |
Usually a negative value that indicates the distance between the pattern and the horizon boundary. |
dist_size |
distance between texture points |
background |
whether the points should have a background (only if grain_size information exists). Either a string with 0 and 1 or the default "random", then the values are selected randomly. |
This function returns a new Simple Features which contains all informations (columns) of the Input Simple Features (shape). Columns with the graphic parameters are added. Adding patterns to the given layer can result in multiple geometries. (e.g. points and lines). To save this information, rows are added to the dataset.
Gabriel Holz
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 | #create an example dataset and modify the color and depths
#The columns grain_size and grain_sd specify the texture.
#If the value is not zero or NA, a point grid is created for the texture.
#With the function par_dafault the grain size can be changed.
#Only for the "AhBv" horizontal there is a function in the package.
#For the other horizons the texture is drawn.
library(dplyr)
library(ggplot2)
df_example <- data.frame(name = c("Bt", "AhBv", "Cve"),
from = c(0, 15, 43.4),
to = c(15, 43.4, 70),
col = c("7.5YR 2/1","10YR 4/3", "2.5Y 5/3"),
skel_dim = c(".5-1","1-2", "2-3"),
skel_ab = c(0.2, 0.6, 1.9),
clay = c(.7, 0, 0),
silt = c(.2, 0, 0),
sand = c(.1, 0, 1)) %>%
data_mod()
#Set coordinates, four points on each horizon
cord_example <- cord_setting(df_example, plot_width = 2)
#create a simple feature: Each line represents a horizon
#with one polygon as geometry.
sf_example <- sf_polygon(df_geom = cord_example,
df_attri = df_example)
## Creation of the patterns
texture_example <- apply_texture(shape = sf_example,
buffer = -1.3)
## Plotting Data
library(ggplot2)
texture_example %>%
ggplot() +
geom_sf() +
soil_theme()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.