Create a density grid from geometries. For use in CartoDB
✓ Published0🌍 Public
Aandrewxhill
Last edited Mar 19, 2012
Created on Mar 19, 2012
This example creates a density grid from point geometries using PostGIS and CartoDB, aggregating points into square cells via `ST_SnapToGrid` and returning cell envelopes with an associated value. It shows both a simple count of points per cell and a version that applies aggregation methods like MAX, MIN, SUM, or AVG to a specified numeric column, such as restaurant ratings or view counts. The functions generate a `CDB_DensityGridPair` type with geometry and float value, enabling thematic mapping of spatial density. An example query uses the grid to visualize cuisine ratings across New York restaurants.
AI-generated description