Skip to contents

From https://observablehq.com/@jwolondon/gridmap-allocation. Creates a list of grid locations of a stated size, with spacer positions removed.

Usage

grid_locations(n_row, n_col, spacers = list())

Arguments

n_row

maximum number of rows defining grid. There must be at least as many grid cells as there are points to allocate.

n_col

maximum number of columns defining grid. There must be at least as many grid cells as there are points to allocate.

spacers

Optional list of grid cell locations defining grid location of fixed spacers which cannot be allocated points. Coordinates are in (row, column) order with origin top-left. Default is an empty array.

Value

A tibble of grid coordinates in the same order as the original array of input points.

Examples

grid_locations(n_row = 3, n_col = 3, spacers = list())
#> # A tibble: 9 × 2
#>     row   col
#>   <int> <int>
#> 1     1     1
#> 2     1     2
#> 3     1     3
#> 4     2     1
#> 5     2     2
#> 6     2     3
#> 7     3     1
#> 8     3     2
#> 9     3     3