Skip to main content

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 !!

CI codecov Code style: black

Anaconda-Server Badge Anaconda-Server Badge

Anaconda-Server Badge

Anaconda-Server Badge

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 :

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


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)

Uploaded Source

Built Distribution

gdf2bokeh-2.3.2-py3-none-any.whl (9.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page