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.
Statistics are available for layers that have been uploaded to and processed by Felt — layers created at runtime with createLayersFromGeoJson cannot be queried for statistics.
Data analysis methods
The SDK offers three complementary approaches to analyze your map data:
1. Aggregates: single statistics
Calculate one or more values (count, sum, average, and so on) across your dataset or a filtered subset. aggregation.methods is required and takes a list, so you can compute several values in one call. attribute must be a numeric attribute, and can be omitted when the only method is "count". The result is an object keyed by method; a value is null when no features match.
// Count all residential buildings
const residentialCount = await felt.getAggregates({
layerId: "buildings",
filters: ["type", "eq", "residential"],
aggregation: { methods: ["count"] }
});
// returns { count: 427 }
// Average and maximum home value in a specific neighborhood
const homeValues = await felt.getAggregates({
layerId: "buildings",
boundary: [-122.43, 47.60, -122.33, 47.62], // neighborhood boundary
aggregation: {
methods: ["avg", "max"],
attribute: "assessed_value"
}
});
// returns { avg: 652850.32, max: 2450000 }2. Categories: group by values
Group features by unique attribute values and calculate a statistic for each group. Each group comes back as { key, value }: key is the attribute value and value is the count (or the aggregation you ask for in values).
3. Histograms: group by numeric ranges
Create bins for numeric data and calculate a statistic for each range. Each bin comes back as { min, max, value }. steps is either an array of break points, { type: "equal-intervals", count }, or, for date attributes, { type: "time-interval", interval }.
Working with filters
You can apply filters in two powerful ways:
At the top level - Affects both which data is included and how values are calculated
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?