top of page
GeoWGS84AI_Logo_edited.jpg

How to Use Bokeh for GIS Data Visualization

10 minutes ago
3 min read

Geospatial interactive visualization has become more significant in the process of analyzing geographical patterns, connections, and datasets based on geographical locations. Static maps are effective in the presentation of geographic data, while interactive maps provide users with the ability to zoom, pan, inspect features individually, and analyze data interactively.


Bokeh is one of the Python-based visualization packages that enables users to create interactive plots and web visualizations. Bokeh is not a dedicated GIS package but can be integrated with the geospatial Python packages, such as GeoPandas, Shapely, and PyProj.


Bokeh for GIS
Bokeh for GIS

What Is Bokeh?


Bokeh is a free and open-source library written in Python that enables users to create visualizations that are interactive and can be viewed through web browsers. It is able to support interactive charts, scatter graphs, geographic data, dashboards, and even web applications.


In GIS analysis, Bokeh can be used in scenarios where one wishes to:


  • Visualize geographic coordinate systems.

  • Work with point-based spatial datasets

  • Generate interactive scatter maps.

  • Hover over geographic data.

  • Zoom and pan on spatial datasets

  • Filter out geographic attributes.

  • Generate a GIS visualization interface using browsers.


One can find that Bokeh is very compatible with Python’s geospatial ecosystem since the spatial datasets can be formatted using GeoPandas and other libraries before visualization using Bokeh.


Why Use Bokeh for GIS Visualization?


Here are some reasons why Bokeh could help with interactive geospatial data analysis.


  1. Interactive Maps


Users have the ability to pan, zoom, and explore spatial data inside a web browser window.


  1. Hover Information


Information about attributes can be shown by using Bokeh hover tools when the user hovers his/her mouse over geographic objects.


  1. Large Dataset Visualization


The Bokeh rendering engine could be beneficial for exploring large datasets of points and other spatial observations.


  1. Python-Based Workflow


For geospatial analysts and programmers, Bokeh can easily be integrated into a Python workflow without implementing a new interactive visualization tool.


  1. Web-Based Output


Bokeh visualizations can be embedded into web pages or applications, making them suitable for browser-based geospatial dashboards.


Loading GIS Data with GeoPandas


GeoPandas can read common GIS formats such as Shapefiles, GeoJSON, and GeoPackage files.

For example:

import geopandas as gpd

gdf = gpd.read_file("cities.geojson")

print(gdf.head())

The resulting GeoDataFrame contains both attribute data and a geometry column.

You can inspect the coordinate reference system using:

print(gdf.crs)

Understanding the CRS is essential before creating a geographic visualization.


Creating a Basic Bokeh GIS Map


Once the spatial data has been prepared, extract the coordinate values and pass them to Bokeh.

from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource

source = ColumnDataSource(gdf)

p = figure(
    title="Interactive GIS Map",
    x_axis_label="Longitude",
    y_axis_label="Latitude",
    width=900,
    height=600
)

p.scatter(
    x="longitude",
    y="latitude",
    source=source,
    size=8
)

show(p)

The exact implementation depends on the structure of your GeoDataFrame. For point datasets, longitude and latitude can be plotted directly.


Using GeoJSON with Bokeh


GeoJSON proves especially valuable when it comes to web-based geographic information systems visualization, as it offers a standardized way to represent geographic data.


GeoJSON object usually includes:


{

"type": "Feature",

"properties": {

"name": "Region A"

},

"geometry": {

"type": "Polygon",

"coordinates": []

}

}


The GeoJSONDataSource of Bokeh can turn such data into a data source suitable for plotting through Bokeh glyphs.


This is especially helpful when visualizing:


  • Countries

  • States

  • Counties

  • Municipal boundaries

  • Land parcels

  • Watersheds

  • Conservation areas


Using the Bokeh Python library makes it possible to create GIS data visualizations with interactive capabilities. By using Bokeh along with GeoPandas, Shapely, GeoJSON, and coordinate reference systems, you will have the ability to create interactive maps where one can investigate spatial objects and their features.


Although Bokeh is not an integrated GIS solution and cannot substitute for GIS software with spatial analysis capabilities, it is especially effective for interactive geospatial dashboards, online visualization, point and polygon maps, thematic visualization, and GIS in Python projects.


For companies dealing with satellite imagery, aerial imagery, drone imagery, vector layers, and other types of geospatial data, Bokeh can become part of the geospatial solution in Python.


To learn more about Bokeh and its geospatial capabilities, click here.


For more information or any questions regarding Bokeh for GIS Data, please don't hesitate to contact us at


USA (HQ): (720) 702–4849




 
 
 

Comments


bottom of page