Function Repository Resource:

# TileBins

Bin data into rectangular tiles

Contributed by: Anton Antonov
 ResourceFunction["TileBins"][mat,s] bins a numerical full 2D array mat into square grid tiles with size s. ResourceFunction["TileBins"][mat,{hx,hy}] bins a numerical full 2D array mat into rectangular grid tiles with x-y sizes {hx,hy}. ResourceFunction["TileBins"][cv,s] bins coordinates-to-value rules cv.

## Details and Options

ResourceFunction["TileBins"] bins data into rectangular tiles.
The result is an association with keys that are polygon objects.
ResourceFunction["TileBins"] accepts the following options:
 "AggregationFunction" Total function to aggregate the data in each tile "PolygonKeys" True determine whether the result keys are polygons
If the option "PolygonKeys" is set to False, then the keys of the result are rectangle centers.
The option "AggregationFunction" is used to aggregate the values within each tile only when coordinates-to-value rules are supplied.

## Examples

### Basic Examples (5)

Create a list of random 2D points:

 In[1]:=

Bin the points:

 In[2]:=
 Out[2]=

Bin the points and get the tile centers as keys:

 In[3]:=
 Out[3]=

Plot points and square bins:

 In[4]:=
 Out[4]=

Plot points and rectangle bins:

 In[5]:=
 Out[5]=

### Scope (4)

Associate random values to 2D data:

 In[6]:=

Bin the data rules:

 In[7]:=
 Out[7]=

Bin the keys of the data rules:

 In[8]:=
 Out[8]=

Check the equivalence:

 In[9]:=
 Out[9]=

### Options (3)

#### AggregationFunction (2)

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

 In[10]:=
 Out[10]=

Compare with the default option value, Total:

 In[11]:=
 Out[11]=

#### PolygonKeys (1)

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

 In[12]:=
 Out[12]=

### Applications (6)

#### Data visualization (4)

Generate data rules:

 In[13]:=

Here we bin the data:

 In[14]:=

Plot points and square bins by coloring each square according to its aggregated value:

 In[15]:=
 Out[15]=

Repeat the visualization above with rectangular tiles instead of square ones:

 In[16]:=
 Out[16]=

#### Make a rectangular grid (2)

You can make rectangular grids:

 In[17]:=
 Out[17]=

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

 In[18]:=
 Out[18]=

### Properties and Relations (3)

The repository function HextileBins has similar design and implementation as TileBins. Here are comparison examples:

 In[19]:=
 Out[19]=

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

 In[20]:=
 In[21]:=
 In[22]:=
 In[23]:=
 Out[23]=

The function GridGraph can be also used to make rectangular grids:

 In[24]:=
 Out[24]=

Here are the corresponding coordinates:

 In[25]:=
 Out[25]=

Here are the corresponding polygons:

 In[26]:=
 Out[26]=

Make a similar grid with TileBins:

 In[27]:=
 Out[27]=

Here are the corresponding coordinates:

 In[28]:=
 Out[28]=

### Neat Examples (1)

Bin data and summarize the values associated to bin centers:

 In[29]:=
 In[30]:=
 Out[30]=

Anton Antonov

## Version History

• 1.0.0 – 05 May 2020