Description Usage Arguments Value Examples
View source: R/basic_geometry.R
This function draws a set of random lines. The functions were developed primarily to visualise roots.
1 2 | basic_random_line(polygon, number = 300, line_length = 0.8,
variation = 1, smoothness = 5, seed = 34)
|
polygon |
A Simple Feature or just a "sfc_MULTIPOLYGON" or "sfc_POLYGON" geometry. |
number |
The number of points from which the lines are to be created (dafault 800) |
line_length |
The size of the buffer around each point. All points in this area will be combined to one line. This means if the buffer is larger, the lines become longer on average. |
variation |
The standard deviation of the random factor for the buffer size. Increasing the value will result in different lengths of the lines. |
smoothness |
Passed on to smooth fuction |
seed |
set seed for reproducible results |
A Linedataset as Simple Feature with a parID column
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 | #create an example dataset
df_example <- data.frame(name = c(1, 2),
from1 = c(0,20),
to1 = c(20, 40),
rgb_col = c("#6F5F4CFF", "#947650FF")
)
#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)
root_example <- basic_random_line(polygon = sf_example[1,],
number = 100,
line_length = 1,
variation = 1,
smoothness = 5)
library(ggplot2)
library(dplyr)
sf_example %>%
ggplot() +
geom_sf(fill = sf_example$rgb_col) +
geom_sf(data = root_example,
size = root_example$id/max(root_example$id),
alpha = .3, col = "white ") +
soil_theme()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.