Skip to content

HeatmapLayer

lonboard.HeatmapLayer

The HeatmapLayer visualizes the spatial distribution of data.

Example:

import geopandas as gpd
from lonboard import Map, HeatmapLayer

# A GeoDataFrame with Point geometries
gdf = gpd.GeoDataFrame()
layer = HeatmapLayer.from_geopandas(gdf,)
map_ = Map(layers=[layer])

aggregation class-attribute instance-attribute

aggregation = traitlets.Unicode(allow_none=True).tag(sync=True)

Defines the type of aggregation operation

Valid values are 'SUM', 'MEAN'.

  • Type: str, optional
  • Default: "SUM"

auto_highlight class-attribute instance-attribute

auto_highlight = traitlets.Bool(False).tag(sync=True)

When true, the current object pointed to by the mouse pointer (when hovered over) is highlighted with highlightColor.

Requires pickable to be True.

  • Type: bool
  • Default: False

debounce_timeout class-attribute instance-attribute

debounce_timeout = traitlets.Int(allow_none=True).tag(sync=True)

Interval in milliseconds during which changes to the viewport don't trigger aggregation.

  • Type: int, optional
  • Default: 500

get_weight class-attribute instance-attribute

get_weight = FloatAccessor()

The weight of each object.

  • Type: FloatAccessor, optional
    • If a number is provided, it is used as the outline width for all objects.
    • If an array is provided, each value in the array will be used as the outline width for the object at the same row index.
  • Default: 1.

intensity class-attribute instance-attribute

intensity = traitlets.Float(allow_none=True).tag(sync=True)

Value that is multiplied with the total weight at a pixel to obtain the final weight.

  • Type: float, optional
  • Default: 1

opacity class-attribute instance-attribute

opacity = traitlets.Float(1, min=0, max=1).tag(sync=True)

The opacity of the layer.

  • Type: float. Must range between 0 and 1.
  • Default: 1

pickable class-attribute instance-attribute

pickable = traitlets.Bool(True).tag(sync=True)

Whether the layer responds to mouse pointer picking events.

This must be set to True for tooltips and other interactive elements to be available. This can also be used to only allow picking on specific layers within a map instance.

Note that picking has some performance overhead in rendering. To get the absolute best rendering performance with large data (at the cost of removing interactivity), set this to False.

  • Type: bool
  • Default: True

radius_pixels class-attribute instance-attribute

radius_pixels = traitlets.Float(allow_none=True).tag(sync=True)

Radius of the circle in pixels, to which the weight of an object is distributed.

  • Type: float, optional
  • Default: 30

threshold class-attribute instance-attribute

threshold = traitlets.Float(allow_none=True, min=0, max=1).tag(sync=True)

Ratio of the fading weight to the max weight, between 0 and 1.

For example, 0.1 affects all pixels with weight under 10% of the max.

Ignored when color_domain is specified.

  • Type: float, optional
  • Default: 0.05

visible class-attribute instance-attribute

visible = traitlets.Bool(True).tag(sync=True)

Whether the layer is visible.

Under most circumstances, using the visible attribute to control the visibility of layers is recommended over removing/adding the layer from the Map.layers list.

In particular, toggling the visible attribute will persist the layer on the JavaScript side, while removing/adding the layer from the Map.layers list will re-download and re-render from scratch.

  • Type: bool
  • Default: True

weights_texture_size class-attribute instance-attribute

weights_texture_size = traitlets.Int(allow_none=True).tag(sync=True)

Specifies the size of weight texture.

  • Type: int, optional
  • Default: 2048

from_geopandas classmethod

from_geopandas(
    gdf: gpd.GeoDataFrame, *, auto_downcast: bool = True, **kwargs
) -> Self

Construct a Layer from a geopandas GeoDataFrame.

The GeoDataFrame will be reprojected to EPSG:4326 if it is not already in that coordinate system.

Parameters:

  • gdf (GeoDataFrame) –

    The GeoDataFrame to set on the layer.

Other Parameters:

Returns:

  • Self

    A Layer with the initialized data.