Skip to content

SolidPolygonLayer

The SolidPolygonLayer renders filled and/or extruded polygons.

import geopandas as gpd
from lonboard import SolidPolygonLayer

# A GeoDataFrame with Polygon geometries
gdf = gpd.GeoDataFrame()
layer = SolidPolygonLayer.from_geopandas(
    gdf,
    get_fill_color=[255, 0, 0],
)

lonboard.SolidPolygonLayer

The SolidPolygonLayer renders filled and/or extruded polygons.

elevation_scale class-attribute instance-attribute

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

Elevation multiplier. The final elevation is calculated by elevation_scale * get_elevation(d). elevation_scale is a handy property to scale all elevation without updating the data.

  • Type: float, optional
  • Default: 1

Remarks:

  • These lines are rendered with GL.LINE and will thus always be 1 pixel wide.
  • Wireframe and solid extrusions are exclusive, you'll need to create two layers with the same data if you want a combined rendering effect.

extruded class-attribute instance-attribute

extruded = traitlets.Bool(allow_none=True).tag(sync=True)

Whether to extrude the polygons (based on the elevations provided by the get_elevation accessor'). If set to False, all polygons will be flat, this generates less geometry and is faster than simply returning 0 from get_elevation.

  • Type: bool, optional
  • Default: False

filled class-attribute instance-attribute

filled = traitlets.Bool(allow_none=True).tag(sync=True)

Whether to fill the polygons (based on the color provided by the get_fill_color accessor).

  • Type: bool, optional
  • Default: True

get_elevation class-attribute instance-attribute

get_elevation = FloatAccessor()

The elevation to extrude each polygon with, in meters.

Only applies if extruded=True.

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

get_fill_color class-attribute instance-attribute

get_fill_color = ColorAccessor()

The fill color of each polygon in the format of [r, g, b, [a]]. Each channel is a number between 0-255 and a is 255 if not supplied.

  • Type: ColorAccessor, optional
    • If a single list or tuple is provided, it is used as the fill color for all polygons.
    • If a numpy or pyarrow array is provided, each value in the array will be used as the fill color for the polygon at the same row index.
  • Default: [0, 0, 0, 255].

get_line_color class-attribute instance-attribute

get_line_color = ColorAccessor()

The line color of each polygon in the format of [r, g, b, [a]]. Each channel is a number between 0-255 and a is 255 if not supplied.

Only applies if extruded=True.

  • Type: ColorAccessor, optional
    • If a single list or tuple is provided, it is used as the line color for all polygons.
    • If a numpy or pyarrow array is provided, each value in the array will be used as the line color for the polygon at the same row index.
  • Default: [0, 0, 0, 255].

wireframe class-attribute instance-attribute

wireframe = traitlets.Bool(allow_none=True).tag(sync=True)

Whether to generate a line wireframe of the polygon. The outline will have "horizontal" lines closing the top and bottom polygons and a vertical line (a "strut") for each vertex on the polygon.

  • Type: bool, optional
  • Default: False

from_geopandas classmethod

from_geopandas(gdf: gpd.GeoDataFrame, **kwargs) -> SolidPolygonLayer

Construct a SolidPolygonLayer 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.

Returns: