basic_random_point: basic random point

Description Usage Arguments Value Examples

Description

This function draws a random pointlayer, with the following helper fuction st_sample

Usage

1

Arguments

polygon

polygon A Simple Feature or just a "sfc_MULTIPOLYGON" or "sfc_POLYGON" geometry.

size

sample size(s) requested; either total size, or a numeric vector with sample sizes for each feature geometry. When sampling polygons, the returned sampling size may differ from the requested size, as the bounding box is sampled, and sampled points intersecting the polygon are returned.

Value

A unit point Simple Feature with an parID column

Examples

 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
df_example <-  data.frame(name = c(1, 2),
                          from1 = c(0,20),
                          to1 = c(20, 40)
)

#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)

lattri_example <- data.frame(name= c(1,2),
                             numberX = c(2, 5),
                             sd = c(1,1),
                             sm = c(TRUE, TRUE)
)

line_example <- line_mod(df = cord_example,
                         line_attri = lattri_example)
#splitting the polygon 
example_profile <- split_polygon(polygon = sf_example,
                                 line = line_example)

#build an random point layer with 80 points
poly_example1 <- basic_random_point(polygon = example_profile[2,],  size = 80)

#plotting

plot(example_profile$geometry)
plot(poly_example1$geometry, add =TRUE, col = "darkblue")

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