TomTom Maps for JavaScript
    Preparing search index...

    Function aggregateIntoCells

    • Groups points into cells, a grid of hexagons or squares or your own polygons, and gives each cell statistics over a value of its points, such as the median price per square metre.

      Type Parameters

      Parameters

      Returns AggregatedCells<S, G>

      A polygon per cell holding at least minCount points, with the statistics as its properties, for any map module to draw, such as CustomGeoJSONModule.

      • A grid cell is found from the point's coordinates alone, so the cost grows with the points, not the cells. Every point with a value and finite coordinates lands in a cell, and the cells around the antimeridian stay side by side, their longitudes past ±180 where needed. A grid cell's id names its grid, column and row: 'hex:3:-2'.
      • Your own polygons are tested point by point, after a bounding-box check. A point inside several of them counts in each.
      • The cell size is fixed. To follow the zoom, aggregate again on the map's zoomend with a size for the new zoom.
      const cells = aggregateIntoCells(listings, {
      grid: 'hex',
      cellSizeKM: 1,
      value: 'pricePerSquareMeter',
      stats: ['median', 'mean', 'count'],
      minCount: 5,
      });
      // Each cell's properties: { median, mean, count }