Skip to content

Analyzing Massive Amounts of Location Data with Honeycomb ​

Honeycomb is a client-side geospatial visualization tool. It runs directly in the web browser, delivering highly responsive interactive maps and charts. However, because of this design, there is a limit (4GB) to the amount of data that can be loaded directly into Honeycomb. You can find more background on the design of Honeycomb here.

Data grain: points or H3 indexes ​

Honeycomb natively supports two different types of data 'grain' (also known as granularity): Object data (points, lines, polygons) or H3-level data. In the first, each row in the dataset is a an object on the map - a specific point, line, or polygon. In the second, each row is an H3 index. If you are not familiar with H3 indexes, you can learn more in this post on the Honeycomb Blog.

Note: Honeycomb also supports individual-level H3 indexes. It will automatically group by H3 before displaying on the map.

Point-level data: raw information ​

Using a dataset where each row is an object provides a high level of flexibility and detail. Because the 'raw' data is available, individual points can be shown on the map. In addition, on-the-fly 'slice and dice' aggregations involving multiple fields are supported, such as computing the total value of sales for failed deliveries.

The main drawback with object-level data is the volume: after 5-10M points it will be too large for Honeycomb to handle. This is often more than enough when analyzing events in the real-world. Not many companies make 5 million parcel deliveries in a single day.

If you are analyzing more than 5-10M objects, there are a few approaches you can take. The first is to apply a filter to the data before it reaches Honeycomb.

Use SQL Parameters to filter data at the source ​

Honeycomb supports SQL Parameters, which allow you to insert placeholders into your data source queries. These placeholders are then filled in at runtime.

There are two types of SQL parameters: normal and context-based. Normal parameters are values that the user can choose - such as Market Name or Order Date. Context parameters transmit the bounds of the current viewport and the zoom level.

Context-based parameters can be used to build a map that displays a dataset with billions of rows, only displaying the data that the user needs to see. These can also be paired with spatial functions like ST_Simplify to reduce the complexity of the data at lower zoom levels. A key advantage of this approach is that it avoids the need to generate map tiles.

Read more on the SQL Parameters page.

  1. Compute pre-aggregated H3 metrics within the database. Another approach to visualizing large datasets is to pre-aggregate key metrics by H3 index. This aggregation drastically reduces the amount of rows that Honeycomb needs to read. This approach is well-suited for business analytics use cases, such as showing the total order volume or number of errors. This approach can even be combined with SQL Parameters, to only fetch relevant H3 indexes that are located within the current viewport. One key design decision behind Honeycomb is to allow the customer to use their data model and database of choice.

H3-level data: pre-aggregated metrics ​

Honeycomb also supports datasets where each row is an H3 index. All rows must be the same resolution, and the resolution will be detected automatically.

Pre-aggregating data to H3 allows for the analysis of effectively infinite amounts of point data. However, the drawback is that the type of analysis or aggregation that will be shown on the map needs to be known upfront. In addition, individual points will not be visible on the map.

Aggregating to H3 is an ideal task for a scalable data warehouse like Snowflake or Databricks, which both have native H3 functions. Functions including H3_LATLNG_TO_CELL() make it easy to generate H3 indexes from points and then group on them to generate metrics.

Below is an example SQL query that takes data on the point-level and aggregates it to H3 level 12.

sql
SELECT
    count(id) as row_count,
    h3_latlng_to_cell(latitude, longitude, 12) as h3_index
FROM
    source_data
GROUP BY
    h3_index

The complete SQL (including a full dbt project template) can be found on Github, and a full write-up of how to build a data pipeline with H3 in Snowflake can be found on the Honeycomb Blog here.