ScatterplotLayer¶
The ScatterplotLayer
renders circles at given coordinates.
Screenshot from Ookla example.
lonboard.ScatterplotLayer ¶
The ScatterplotLayer
renders circles at given coordinates.
Example:
import geopandas as gpd
from lonboard import ScatterplotLayer
# A GeoDataFrame with Point geometries
gdf = gpd.GeoDataFrame()
layer = ScatterplotLayer.from_geopandas(
gdf,
get_fill_color=[255, 0, 0],
)
antialiasing
class-attribute
instance-attribute
¶
antialiasing = traitlets.Bool(allow_none=True).tag(sync=True)
If True
, circles are rendered with smoothed edges. If False
, circles are
rendered with rough edges. Antialiasing can cause artifacts on edges of overlapping
circles.
- Type:
bool
, optional - Default:
True
billboard
class-attribute
instance-attribute
¶
billboard = traitlets.Bool(allow_none=True).tag(sync=True)
If True
, rendered circles always face the camera. If False
circles face up (i.e.
are parallel with the ground plane).
- Type:
bool
, optional - Default:
False
filled
class-attribute
instance-attribute
¶
filled = traitlets.Bool(allow_none=True).tag(sync=True)
Draw the filled area of points.
- Type:
bool
, optional - Default:
True
get_fill_color
class-attribute
instance-attribute
¶
get_fill_color = ColorAccessor()
The filled color of each object 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
ortuple
is provided, it is used as the filled color for all objects. - If a numpy or pyarrow array is provided, each value in the array will be used as the filled color for the object at the same row index.
- If a single
- Default:
[0, 0, 0, 255]
.
get_line_color
class-attribute
instance-attribute
¶
get_line_color = ColorAccessor()
The outline color of each object 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
ortuple
is provided, it is used as the outline color for all objects. - If a numpy or pyarrow array is provided, each value in the array will be used as the outline color for the object at the same row index.
- If a single
- Default:
[0, 0, 0, 255]
.
get_line_width
class-attribute
instance-attribute
¶
get_line_width = FloatAccessor()
The width of the outline of each object, in units specified by line_width_units
(default 'meters'
).
- 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
.
get_radius
class-attribute
instance-attribute
¶
get_radius = FloatAccessor()
The radius of each object, in units specified by radius_units
(default
'meters'
).
- Type: FloatAccessor, optional
- If a number is provided, it is used as the radius for all objects.
- If an array is provided, each value in the array will be used as the radius for the object at the same row index.
- Default:
1
.
line_width_max_pixels
class-attribute
instance-attribute
¶
line_width_max_pixels = traitlets.Float(allow_none=True).tag(sync=True)
The maximum line width in pixels. This can be used to prevent the stroke from getting too thick when zoomed in.
- Type:
float
, optional - Default:
None
line_width_min_pixels
class-attribute
instance-attribute
¶
line_width_min_pixels = traitlets.Float(allow_none=True).tag(sync=True)
The minimum line width in pixels. This can be used to prevent the stroke from getting too thin when zoomed out.
- Type:
float
, optional - Default:
0
line_width_scale
class-attribute
instance-attribute
¶
line_width_scale = traitlets.Float(allow_none=True).tag(sync=True)
A global line width multiplier for all points.
- Type:
float
, optional - Default:
1
line_width_units
class-attribute
instance-attribute
¶
line_width_units = traitlets.Float(allow_none=True).tag(sync=True)
The units of the line width, one of 'meters'
, 'common'
, and 'pixels'
. See
unit
system.
- Type:
str
, optional - Default:
'meters'
radius_max_pixels
class-attribute
instance-attribute
¶
radius_max_pixels = traitlets.Float(allow_none=True).tag(sync=True)
The maximum radius in pixels. This can be used to prevent the circle from getting too big when zoomed in.
- Type:
float
, optional - Default:
None
radius_min_pixels
class-attribute
instance-attribute
¶
radius_min_pixels = traitlets.Float(allow_none=True).tag(sync=True)
The minimum radius in pixels. This can be used to prevent the circle from getting too small when zoomed out.
- Type:
float
, optional - Default:
0
radius_scale
class-attribute
instance-attribute
¶
radius_scale = traitlets.Float(allow_none=True).tag(sync=True)
A global radius multiplier for all points.
- Type:
float
, optional - Default:
1
radius_units
class-attribute
instance-attribute
¶
radius_units = traitlets.Unicode('meters', allow_none=True).tag(sync=True)
The units of the radius, one of 'meters'
, 'common'
, and 'pixels'
. See unit
system.
- Type:
str
, optional - Default:
'meters'
stroked
class-attribute
instance-attribute
¶
stroked = traitlets.Bool(allow_none=True).tag(sync=True)
Draw the outline of points.
- Type:
bool
, optional - Default:
False
from_geopandas
classmethod
¶
from_geopandas(gdf: gpd.GeoDataFrame, **kwargs) -> ScatterplotLayer
Construct a ScatterplotLayer 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:
-
ScatterplotLayer
–A ScatterplotLayer with the initialized data.