This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH hgrid AS | |
(SELECT CDB_HexagonGrid(ST_Expand(CDB_XYZ_Extent(/* INSERT TILE XYZ SOMEHOW */), CDB_XYZ_Resolution(/* CURRENT ZOOM */) * 15), CDB_XYZ_Resolution(/* CURRENT ZOOM */) * 15) AS cell) | |
SELECT hgrid.cell AS the_geom_webmercator, | |
count(i.cartodb_id) AS points_count, | |
count(i.cartodb_id)/power(15 * CDB_XYZ_Resolution(/* CURRENT ZOOM */), 2) AS points_density, | |
1 AS cartodb_id | |
FROM hgrid, | |
(SELECT * | |
FROM /* TABLE NAME HERE */) i | |
WHERE ST_Intersects(i.the_geom_webmercator, hgrid.cell) |