Gdf2Bokeh is able to map your data from various format. About data, you must be aware to use compliant geometry types:
It supports data containing these geometries families:
GeometryCollection data are not supported, so explode it to use it. So the best practice consists to split your input data by geometry type.
And you'll be able, optionally, to style your data thanks to the bokeh arguments : Check bokeh documentation in order to style your data :
import geopandas as gpd
from bokeh.plotting import output_notebook
from bokeh.plotting import show
from gdf2bokeh import Gdf2Bokeh
output_notebook()
layers_to_map = [
{
# contains both Polygon and MultiPolygon features
"title": "[Multi]Polygons layer",
"data": gpd.GeoDataFrame.from_file("tests/fixtures/multipolygons.geojson"),
"from_epsg": 4326,
"fill_color": "orange"
},
{
"title": "Polygons layer",
"data": gpd.GeoDataFrame.from_file("tests/fixtures/polygons.geojson"),
"from_epsg": 4326,
"fill_color": "red",
"line_color": "black"
},
{
"title": "LineString layer",
"data": gpd.GeoDataFrame.from_file("tests/fixtures/linestrings.geojson"),
"from_epsg": 4326,
"color": "color", # we can use the attribute called 'color' containing name color (as usual on bokeh)
"line_width": 4
},
{
# contains both LineString and MultiLineString features
"title": "Multi[LineStrings] layer",
"data": gpd.GeoDataFrame.from_file("tests/fixtures/multilinestrings.geojson"),
"from_epsg": 4326,
"color": "blue",
"line_width": 6
},
{
"title": "MultiPoints layer",
"data": gpd.GeoDataFrame.from_file("tests/fixtures/multipoints.geojson"),
"from_epsg": 4326,
"size": 12,
"fill_color": "yellow",
"line_color": "blue"
},
{
"title": "Points layer",
"data": gpd.GeoDataFrame.from_file("tests/fixtures/points.geojson"),
"from_epsg": 4326,
"size": 6,
"fill_color": "red",
"line_color": "blue"
},
]
%%time
map_session = Gdf2Bokeh(
"My beautiful map",
width=800,
height=600,
background_map_name="CARTODBPOSITRON"
)
for layer in layers_to_map:
map_session.add_layer_from_geodataframe(**layer)
map_session.add_layers_on_maps()
show(map_session.figure)
CPU times: user 251 ms, sys: 181 µs, total: 251 ms Wall time: 251 ms