Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Bin data into rectangular tiles
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. |
"AggregationFunction" | Total | function to aggregate the data in each tile |
"PolygonKeys" | True | determine whether the result keys are polygons |
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]= | ![]() |
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]= | ![]() |
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]= | ![]() |
Instead of polygons as keys, you can get the centers of the polygons:
In[12]:= | ![]() |
Out[12]= | ![]() |
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]= | ![]() |
You can make rectangular grids:
In[17]:= | ![]() |
Out[17]= | ![]() |
The coordinates of the polygons can be retrieved and transformed further:
In[18]:= | ![]() |
Out[18]= | ![]() |
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]= | ![]() |
Bin data and summarize the values associated to bin centers:
In[29]:= | ![]() |
In[30]:= | ![]() |
Out[30]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License