The ScatterplotLayer
renders circles at given coordinates.
import geopandas as gpd
from lonboard import Map, ScatterplotLayer
# A GeoDataFrame with Point or MultiPoint geometries
gdf = gpd.GeoDataFrame()
layer = ScatterplotLayer.from_geopandas(
gdf,
get_fill_color=[255, 0, 0],
)
m = Map(layer)
from geoarrow.rust.io import read_parquet
from lonboard import Map, ScatterplotLayer
# Example: A GeoParquet file with Point or MultiPoint geometries
table = read_parquet("path/to/file.parquet")
layer = ScatterplotLayer(
table=table,
get_fill_color=[255, 0, 0],
)
m = Map(layer)
antialiasing class-attribute
instance-attribute
¶
antialiasing = 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.
bool
, optionalTrue
class-attribute
instance-attribute
¶
auto_highlight = 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
.
bool
False
class-attribute
instance-attribute
¶
billboard = tag(sync=True)
If True
, rendered circles always face the camera. If False
circles face up (i.e. are parallel with the ground plane).
bool
, optionalFalse
class-attribute
instance-attribute
¶
extensions = tag(sync=True, **widget_serialization)
A list of layer extension objects to add additional features to a layer.
filledclass-attribute
instance-attribute
¶
Draw the filled area of points.
bool
, optionalTrue
class-attribute
instance-attribute
¶
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.
list
or tuple
is provided, it is used as the filled color for all objects.[0, 0, 0, 255]
.class-attribute
instance-attribute
¶
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.
list
or tuple
is provided, it is used as the outline color for all objects.[0, 0, 0, 255]
.class-attribute
instance-attribute
¶
The width of the outline of each object, in units specified by line_width_units
(default 'meters'
).
1
.class-attribute
instance-attribute
¶
The radius of each object, in units specified by radius_units
(default 'meters'
).
1
.class-attribute
instance-attribute
¶
highlight_color = VariableLengthTuple(
Int(), default_value=None, minlen=3, maxlen=4
)
RGBA color to blend with the highlighted object (the hovered over object if auto_highlight=true
). When the value is a 3 component (RGB) array, a default alpha of 255 is applied.
[0, 0, 128, 128]
class-attribute
instance-attribute
¶
line_width_max_pixels = tag(sync=True)
The maximum line width in pixels. This can be used to prevent the stroke from getting too thick when zoomed in.
float
, optionalNone
class-attribute
instance-attribute
¶
line_width_min_pixels = tag(sync=True)
The minimum line width in pixels. This can be used to prevent the stroke from getting too thin when zoomed out.
float
, optional0
class-attribute
instance-attribute
¶
line_width_scale = tag(sync=True)
A global line width multiplier for all points.
float
, optional1
class-attribute
instance-attribute
¶
line_width_units = tag(sync=True)
The units of the line width, one of 'meters'
, 'common'
, and 'pixels'
. See unit system.
str
, optional'meters'
class-attribute
instance-attribute
¶
The opacity of the layer.
float
. Must range between 0 and 1.1
class-attribute
instance-attribute
¶
pickable = 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
.
bool
True
class-attribute
instance-attribute
¶
radius_max_pixels = tag(sync=True)
The maximum radius in pixels. This can be used to prevent the circle from getting too big when zoomed in.
float
, optionalNone
class-attribute
instance-attribute
¶
radius_min_pixels = tag(sync=True)
The minimum radius in pixels. This can be used to prevent the circle from getting too small when zoomed out.
float
, optional0
class-attribute
instance-attribute
¶
radius_scale = tag(sync=True)
A global radius multiplier for all points.
float
, optional1
class-attribute
instance-attribute
¶
radius_units = tag(sync=True)
The units of the radius, one of 'meters'
, 'common'
, and 'pixels'
. See unit system.
str
, optional'meters'
class-attribute
instance-attribute
¶
selected_index = tag(sync=True)
The positional index of the most-recently clicked on row of data.
You can use this to access the full row of data from a GeoDataFrame
gdf.iloc[layer.selected_index]
Setting a value here from Python will do nothing. This attribute only exists to be updated from JavaScript on a map click. Note that pickable
must be True
(the default) on this layer for the JavaScript onClick
handler to work; if pickable
is set to False
, selected_index
will never update.
Note that you can use observe
to call a function whenever a new value is received from JavaScript. Refer here for an example.
class-attribute
instance-attribute
¶
Draw the outline of points.
bool
, optionalFalse
class-attribute
instance-attribute
¶
A GeoArrow table with a Point or MultiPoint column.
This is the fastest way to plot data from an existing GeoArrow source, such as geoarrow-rust or geoarrow-pyarrow.
If you have a GeoPandas GeoDataFrame
, use from_geopandas
instead.
class-attribute
instance-attribute
¶
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.
bool
True
__init__(
table: ArrowStreamExportable,
*,
_rows_per_chunk: int | None = None,
**kwargs: Unpack[ScatterplotLayerKwargs]
) -> None
Construct a Layer from a GeoArrow table.
This accepts Arrow data from any library implementing the Arrow PyCapsule Interface, including pyarrow, arro3, DuckDB, and others.
The geometry column will be reprojected to EPSG:4326
if it is not already in that coordinate system.
Parameters:
table
(ArrowStreamExportable
) –
An Arrow table or stream object from a library implementing the [Arrow PyCapsule Interface]. This object must contain a column with a geometry type that has the geoarrow
extension metadata.
Other Parameters:
kwargs
(Unpack[BaseLayerKwargs]
) –
parameters passed on to __init__
Returns:
None
–
A Layer with the initialized data.
classmethod
¶
Construct a Layer from a duckdb-spatial query.
DuckDB Spatial does not currently expose coordinate reference system information, so the user must ensure that data has been reprojected to EPSG:4326 or pass in the existing CRS of the data in the crs
keyword parameter.
Parameters:
sql
(str | DuckDBPyRelation
) –
The SQL input to visualize. This can either be a string containing a SQL query or the output of the duckdb sql
function.
con
(DuckDBPyConnection | None
, default: None
) –
The current DuckDB connection. This is required when passing a str
to the sql
parameter.
Other Parameters:
crs
(str | CRS | None
) –
The CRS of the input data. This can either be a string passed to pyproj.CRS.from_user_input
or a pyproj.CRS
object. Defaults to None.
kwargs
(Unpack[BaseLayerKwargs]
) –
parameters passed on to __init__
Returns:
Self
–
A Layer with the initialized data.
classmethod
¶
from_geopandas(
gdf: GeoDataFrame,
*,
auto_downcast: bool = True,
**kwargs: Unpack[ScatterplotLayerKwargs]
) -> 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:
auto_downcast
(bool
) –
If True
, automatically downcast to smaller-size data types if possible without loss of precision. This calls pandas.DataFrame.convert_dtypes and pandas.to_numeric under the hood.
kwargs
(Unpack[BaseLayerKwargs]
) –
parameters passed on to __init__
Returns:
Self
–
A Layer with the initialized data.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4