Skip to contents

This function generates the coordinates of hexagons after passing hexagonal centroids.

Usage

gen_hex_coord(centroids_df, a1)

Arguments

centroids_df

The dataset with all hexagonal bin IDs and centroid coordinates.

a1

The width of the hexagon.

Value

A tibble contains polygon id, x and y coordinates (hex_poly_id, x, and y respectively) of hexagons.

Examples

r2 <- diff(range(s_curve_noise_umap$UMAP2))/diff(range(s_curve_noise_umap$UMAP1))
num_bins_list <- calc_bins_y(bin1 = 4, r2 = r2, q = 0.1)
width <- num_bins_list$a1
all_centroids_df <- gen_centroids(bin1 = 4, r2 = r2, q = 0.1)
gen_hex_coord(centroids_df = all_centroids_df, a1 = width)
#> # A tibble: 192 × 3
#>    hex_poly_id       x       y
#>          <int>   <dbl>   <dbl>
#>  1           1 -0.1     0.0191
#>  2           1 -0.291  -0.0914
#>  3           1 -0.291  -0.312 
#>  4           1 -0.1    -0.423 
#>  5           1  0.0915 -0.312 
#>  6           1  0.0915 -0.0914
#>  7           2  0.283   0.0191
#>  8           2  0.0915 -0.0914
#>  9           2  0.0915 -0.312 
#> 10           2  0.283  -0.423 
#> # ℹ 182 more rows