pydeck module¶
leafmap.deck
¶
Layer
¶
Bases: Layer
Configures a deck.gl layer for rendering on a map. Parameters passed here will be specific to the particular deck.gl layer that you are choosing to use. Please see the deck.gl Layer catalog (https://deck.gl/docs/api-reference/layers) to determine the particular parameters of your layer. You are highly encouraged to look at the examples in the pydeck documentation.
__init__(type, data=None, id=None, use_binary_transport=None, **kwargs)
¶
Initialize a Layer object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
str
|
Type of layer to render, e.g., HexagonLayer. See deck.gl Layer catalog (https://deck.gl/docs/api-reference/layers) |
required |
data
|
str
|
Unique name for layer. Defaults to None. |
None
|
id
|
str | dict | DataFrame
|
Either a URL of data to load in or an array of data. Defaults to None. |
None
|
use_binary_transport
|
bool
|
Boolean indicating binary data. Defaults to None. |
None
|
Map
¶
Bases: Deck
The Map class inherits pydeck.Deck.
__init__(center=(20, 0), zoom=1.2, **kwargs)
¶
Initialize a Map object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
tuple
|
Center of the map in the format of (lat, lon). Defaults to (20, 0). |
(20, 0)
|
zoom
|
int
|
The map zoom level. Defaults to 1.2. |
1.2
|
add_basemap(basemap='HYBRID')
¶
Adds a basemap to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basemap
|
str
|
Can be one of string from pydeck_basemaps. Defaults to 'HYBRID'. |
'HYBRID'
|
add_gdf(gdf, layer_type='GeoJsonLayer', layer_name=None, random_color_column=None, **kwargs)
¶
Adds a GeoPandas GeoDataFrame to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
The GeoPandas GeoDataFrame to add to the map. |
required |
layer_type
|
str
|
The layer type to be used. Defaults to "GeoJsonLayer". |
'GeoJsonLayer'
|
layer_name
|
str
|
The layer name to be used. Defaults to None. |
None
|
random_color_column
|
str
|
The column name to use for random color. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
gdf must be a GeoPandas GeoDataFrame. |
add_geojson(filename, layer_name=None, random_color_column=None, **kwargs)
¶
Adds a GeoJSON file to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The input file path to the vector dataset. |
required |
layer_name
|
str
|
The layer name to be used. Defaults to None. |
None
|
random_color_column
|
str
|
The column name to use for random color. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
The provided vector file could not be found. |
add_kml(filename, layer_name=None, random_color_column=None, **kwargs)
¶
Adds a KML file to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The input file path to the vector dataset. |
required |
layer_name
|
str
|
The layer name to be used. Defaults to None. |
None
|
random_color_column
|
str
|
The column name to use for random color. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
The provided vector file could not be found. |
add_layer(layer, layer_name=None, **kwargs)
¶
Add a layer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
Layer
|
A pydeck Layer object. |
required |
add_shp(filename, layer_name=None, random_color_column=None, **kwargs)
¶
Adds a shapefile to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The input file path to the vector dataset. |
required |
layer_name
|
str
|
The layer name to be used. Defaults to None. |
None
|
random_color_column
|
str
|
The column name to use for random color. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
The provided vector file could not be found. |
add_vector(data, layer_type='GeoJsonLayer', layer_name=None, random_color_column=None, **kwargs)
¶
Adds a vector file to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
The input file path to the vector dataset. |
required |
layer_type
|
str
|
The layer type to be used. Defaults to "GeoJsonLayer". |
'GeoJsonLayer'
|
layer_name
|
str
|
The layer name to be used. Defaults to None. |
None
|
random_color_column
|
str
|
The column name to use for random color. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
The provided vector file could not be found. |