Skip to contents

From the coordinates of a segment, this function returns the coordinates of equidistant points along the segment given a number of points

Usage

get_section_centers(node_coords, nb_sections)

Arguments

node_coords

2-rows matrix, with coordinates of segment boundaries

nb_sections

1-length numeric, number of points to extract

Value

A matrix with the coordinates of the points along the segment

Examples

node_coords <- matrix(c(102550, 102550, 110000, 108000), ncol = 2)
reach_length <- as.numeric(dist(node_coords[1:2,]))
space_step <- 100
nb_sections <- ceiling(reach_length / space_step) + 1
get_section_centers(node_coords, nb_sections)
#>         [,1]   [,2]
#>  [1,] 102550 110000
#>  [2,] 102550 109900
#>  [3,] 102550 109800
#>  [4,] 102550 109700
#>  [5,] 102550 109600
#>  [6,] 102550 109500
#>  [7,] 102550 109400
#>  [8,] 102550 109300
#>  [9,] 102550 109200
#> [10,] 102550 109100
#> [11,] 102550 109000
#> [12,] 102550 108900
#> [13,] 102550 108800
#> [14,] 102550 108700
#> [15,] 102550 108600
#> [16,] 102550 108500
#> [17,] 102550 108400
#> [18,] 102550 108300
#> [19,] 102550 108200
#> [20,] 102550 108100
#> [21,] 102550 108000