I have a a PostgreSQL database table with the following simplified structure:
Basica
select [some aggregates] group by (pos_x/5, pos_y/5);
Where instead of 5 you can have any number depending how much aggregation you need/