Building custom charts

The Felt SDK provides powerful methods to analyze your geospatial data and transform it into informative visualizations. You can calculate statistics on entire datasets or focus on specific areas using boundaries and filters, allowing you to create custom charts that reveal insights about your spatial data.

Data analysis methods

The SDK offers three complementary approaches to analyze your map data:

1. Aggregates: single statistics

Calculate individual values (count, sum, average, etc.) across your dataset or a filtered subset. If no aggregation method is provided, the count is returned.

// Count all residential buildings
const residentialCount = await felt.getAggregates({
    layerId: "buildings",
    filters: ["type", "eq", "residential"]
});
// returns { count: 427 }

// Calculate average home value in a specific neighborhood
const avgHomeValue = await felt.getAggregates({
    layerId: "buildings",
    boundary: [-122.43, 47.60, -122.33, 47.62], // neighborhood boundary
    aggregation: {
        method: "avg",
        attribute: "assessed_value"
    }
});
// returns { avg: 652850.32 }

2. Categories: group by values

Group features by unique attribute values and calculate statistics for each group.

3. Histograms: group by numeric ranges

Create bins for numeric data and calculate statistics for each range.

Working with filters

You can apply filters in two powerful ways:

  1. At the top level - Affects both which data is included and how values are calculated

  2. In the values configuration - Only affects the calculated values while keeping all categories/bins

This two-level filtering is especially useful for creating comparative visualizations while maintaining consistent groupings.

Advanced filtering examples

Comparing building types by floor area (Categories)

Comparing building heights across time periods (Histograms)

Comparing neighborhood density (Aggregates)

Interactive visualization example

Here's how you might integrate these analysis methods with an interactive chart:

This example demonstrates how a user clicking on a pie chart slice could apply a filter to the map, highlighting only the buildings of that type. It also shows how you could fetch additional statistics based on the user's selection to enrich the visualization experience.

Last updated

Was this helpful?