Skip to content



Adds GPU-based data filtering functionalities to layers. It allows the layer to show/hide objects based on user-defined properties.


from lonboard import Map, ScatterplotLayer
from lonboard.colormap import apply_continuous_cmap
from lonboard.layer_extension import DataFilterExtension

gdf = gpd.GeoDataFrame(...)
extension = DataFilterExtension()
layer = ScatterplotLayer.from_geopandas(
    get_filter_value=gdf["filter_value"], # replace with desired column
    filter_range=[0, 5] # replace with desired filter range

The DataFilterExtension allows filtering on 1 to 4 attributes at the same time. So if you have four numeric columns of interest, you can filter on the intersection of all of them.

For easy visualization, we suggest connecting the DataFilterExtension to an interactive slider from ipywidgets.

from ipywidgets import FloatRangeSlider

slider = FloatRangeSlider(
    value=(2, 5),
    description="Slider: "

    (slider, "value"),
    (layer, "filter_range")

If you have 2 to 4 columns, use a MultiRangeSlider, which combines multiple FloatRangeSlider objects in a form that the DataFilterExtension expects.

from ipywidgets import FloatRangeSlider, jsdlink

slider1 = FloatRangeSlider(
    value=(2, 5),
    description="First slider: "
slider2 = FloatRangeSlider(
    value=(30, 40),
    description="Second slider: "
multi_slider = MultiRangeSlider([slider1, slider2])

    (multi_slider, "value"),
    (layer, "filter_range")

Important notes

  • The DataFilterExtension only supports float32 data, so integer data will be casted to float32.
  • The DataFilterExtension copies all data referenced by get_filter_value to the GPU, so it will increase memory pressure on the GPU.

Layer Properties

This extension dynamically enables the following properties onto the layer(s) where it is included:


Enable/disable the data filter. If the data filter is disabled, all objects are rendered.

  • Type: bool, optional
  • Default: True


The bounds which defines whether an object should be rendered. If an object's filtered value is within the bounds, the object will be rendered; otherwise it will be hidden. This prop can be updated on user input or animation with very little cost.


If filter_size is 1, provide a single tuple of (min, max).

If filter_size is 2 to 4, provide a list of tuples: [(min0, max0), (min1, max1), ...] for each filtered property, respectively.

  • Type: either Tuple[float, float] or List[Tuple[float, float]], optional
  • Default: (-1, 1)


If specified, objects will be faded in/out instead of abruptly shown/hidden.

When the filtered value is outside of the bounds defined by filter_soft_range but still within the bounds defined by filter_range, the object will be rendered as "faded".

  • Type: Tuple[float, float], optional
  • Default: None


When an object is "faded", manipulate its size so that it appears smaller or thinner. Only works if filter_soft_range is specified.

  • Type: bool, optional
  • Default: True


When an object is "faded", manipulate its opacity so that it appears more translucent. Only works if filter_soft_range is specified.

  • Type: bool, optional
  • Default: True


Accessor to retrieve the value for each object that it will be filtered by.

  • Type: FilterValueAccessor
    • If a scalar value is provided, it is used as the value for all objects.
    • If an array is provided, each value in the array will be used as the value for the object at the same row index.

filter_size class-attribute instance-attribute

filter_size = tag(sync=True)

The size of the filter (number of columns to filter by).

The data filter can show/hide data based on 1-4 numeric properties of each object.

  • Type: int, optional
  • Default 1.