# Function Repository Resource:

# HextileBins

Bin data into hexagon tiles

Contributed by: Anton Antonov
 ResourceFunction["HextileBins"][mat,r] bins a numerical full 2D array mat into hexagon grid tiles with radius r. ResourceFunction["HextileBins"][cv,r] bins coordinates-to-value rules cv.

## Details and Options

ResourceFunction["HextileBins"] bins data into hexagon tiles.
The result is an association with keys that are Polygon objects.
If the option "PolygonKeys" is set to False, then the keys of the result are hexagon centers.
The option "AggregationFunction" is used to aggregate the values within each tile.
 "AggregationFunction" Total function to aggegate the data in each tile "PolygonKeys" True are the result keys polygons

## Examples

### Basic Examples (4)

Create a list of random 2D points:

 In:= Bin the points:

 In:= Out= Bin the points and get the hex-tile centers as keys:

 In:= Out= Plot the points and the hexagon bins:

 In:= Out= ### Scope (4)

Associate random values to 2D data:

 In:= Bin the data rules:

 In:= Out= Bin the keys of the data rules:

 In:= Out= Check the equivalence:

 In:= Out= ### Options (3)

#### AggregationFunction (2)

Bin the data rules and compute average values on each tile:

 In:= Out= Compare with the default option value Total:

 In:= Out= #### PolygonKeys (1)

Instead of polygons as keys, you can get the centers of the polygons:

 In:= Out= ### Applications (5)

#### Data visualization (3)

Generate data rules:

 In:= Here we bin the data:

 In:= Plot points and hexagon bins by coloring each hexagon according to its aggregated value:

 In:= Out= #### Make a hexagonal grid (2)

You can make hexagonal grids:

 In:= Out= The coordinates of the polygons can be retrieved and transformed further:

 In:= Out= ### Properties and Relations (3)

The function GeoHistogram produces similar plots (in Version 12.1):

 In:= In:= In:= In:= Out= The resource function HexagonalGridGraph can be also used to make hexagonal grids:

 In:= Out= Here are the corresponding coordinates:

 In:= Out= Here are the corresponding polygons:

 In:= Out= Make a similar grid with HextileBins:

 In:= Out= Here are the corresponding coordinates:

 In:= Out= The resource function TileBins has similar design and implementation as HextileBins. Here are comparable examples:

 In:= Out= ### Neat Examples (1)

Bin data and summarize the values associated with bin centers:

 In:= In:= Out= Anton Antonov

## Version History

• 2.0.0 – 11 November 2020

## Author Notes

Initial ideas/versions of the code of HextileBins can be found in Mathematica Stack Exchange: https://mathematica.stackexchange.com/q/28149.