An easy way to map geodataframes on bokeh
Project description
gdf2bokeh
An easy way to map your geographic data (from a GeoDataFrame) with bokeh >=2.3 Because it's boring to convert shapely geometry to bokeh format !!
How to install the conda package ?
With Anaconda
conda install -c amauryval gdf2bokeh
with pip
pip install gdf2bokeh
How to use it ?!
A small example :
Check bokeh documentation in order to style your data :
- bokeh marker style options to style point features
- bokeh multi_line style options to style LineString and MultiLineString features
- bokeh multi_polygon style options to style polygon and multipolygons features
from bokeh.plotting import show
import geopandas as gpd
from gdf2bokeh import Gdf2Bokeh
layers_to_add = [
{
"input_gdf": gpd.GeoDataFrame.from_file("your_geo_layer.geojson"),
"legend": "My beautiful layer", # required, can be the name of an column name (from your input gdf)
"fill_color": "orange", # here we found one argument use by bokeh to style your layer. Take care about geometry type
},
{
"input_wkt": "LINESTRING(0 0, 25 25)", # you can add an input wkt
"legend": "My beautiful layer", # required
"color": "orange", # here we found one argument use by bokeh to style your layer. Take care about geometry type
}
]
# Points, LineString, MultiLineString, Polygons (+ holes) and MultiPolygons (+ holes) are supported
my_map = Gdf2Bokeh(
"My beautiful map", # required: map title
width=800, # optional: figure width, default 800
height=600, # optional: figure width, default 600
x_range=None, # optional: x_range, default None
y_range=None, # optional: y_range, default None
background_map_name="CARTODBPOSITRON", # optional: background map name, default: CARTODBPOSITRON
layers=layers_to_add # optional: bokeh layer to add from a list of dict contains geodataframe settings, see dict above
)
# to get all the bokeh layer containers (dict), in order to update them (interactivity, slider... on a bokeh serve)
bokeh_layer_containers = my_map.get_bokeh_layer_containers
show(my_map.figure)
Also, you can find a bokeh serve example with a slider widget. On the terminal, run :
bokeh serve --show bokeh_serve_example.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gdf2bokeh-2.3.2.tar.gz
(9.2 kB
view hashes)
Built Distribution
Close
Hashes for gdf2bokeh-2.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 449ba4b81170317a01aefad6614ea50b61a6f5d649b53ed7c1fc9e45164ad2ab |
|
MD5 | 3ff2608473cfddd99813a807f3664362 |
|
BLAKE2b-256 | 70ad14a03549a8467b3e075b8c96104deed7d825398411bce9f9de8dadfd2108 |