line_mod: creates a line as simple feature

Description Usage Arguments Value Examples

View source: R/line_mod.R

Description

This is a simple function that creates a simple feature line from the horizont coordinates.

Usage

1
line_mod(df_geom, line_attri, seed = 33)

Arguments

df_geom

A long table with the columns named "name", "x" and "y" (Id and coordinates) for each horizont. For example created by the cord_setting function

line_attri

A datan frame with the information about the lines which divide the horizons. The following columns must exist:

  1. The horizon Id must be given in a numeric column named "name"

  2. The number of X points, which should deviate the line from a straight line, must be given in a numeric column named: "numberX"

  3. The distance between the X points and the straight line must be given in a numeric column named: "sd". The values are calculated using the rnorm function. The mean value is given by the X-value of the straight horizon line. And the standard deviation can be selected individually.

  4. The column named "sm" can be used as a logical value to specify whether the horizon transition should be smoothed. This is done with the function smooth.

seed

For replicable examples a seed can be set here

Value

This function returns a linestring simple feature. Each line represents the upper horizontal limit of the corresponding id.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Example data
data_example <- data.frame(name = c(1, 2),
                          from1 = c(0,20),
                          to1 = c(20, 40)
)

##Coordination setting
cord_example <- cord_setting(data_example, plot_width = 3)

## Line attributes data frame:
lattri_example <- data.frame(name= unique(cord_example$name),
                            numberX = c(2, 10), 
                            sd = c(1,1),
                            sm = c(TRUE, TRUE)
)

## Apply the line_mod fuction
line_example <- line_mod(df_geom = cord_example, line_attri = lattri_example)

## Plot simple feature geometry
plot(line_example$geometry)

nardusstricta/soilprofile2 documentation built on May 23, 2019, 6:04 p.m.