geeViz.outputLib.charts

Zonal Summary & Charting Library for GEE

geeViz.outputLib.charts provides a Python pipeline for running zonal statistics on ee.Image / ee.ImageCollection objects and producing Plotly charts (time series, bar, sankey). It mirrors the logic in the geeView JS frontend so that both human users and AI agents have a clean, efficient API for this common workflow.

Quick start:

>>> import geeViz.geeView as gv
>>> from geeViz.outputLib import charts as cl
>>> ee = gv.ee
>>> study_area = ee.Geometry.Polygon(
...     [[[-106, 39.5], [-105, 39.5], [-105, 40.5], [-106, 40.5]]]
... )
>>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2024-10")
>>> df, fig = cl.summarize_and_chart(
...     lcms.select(['Land_Cover']),
...     study_area,
...     stacked=True,
... )
>>> print(df.to_markdown())
>>> fig.write_html("chart.html", include_plotlyjs="cdn")

See summarize_and_chart() for the full API and more examples.

Module Attributes

CHART_TYPES

Valid chart type strings for chart_type / chart_types parameters.

Functions

chart_bar(df[, colors, title, y_label, ...])

Create a Plotly bar chart from a single-Image zonal stats DataFrame.

chart_donut(df[, colors, title, ...])

Create a Plotly donut chart from a single-Image zonal stats DataFrame.

chart_donut_multi_feature(df[, colors, ...])

Create a subplot grid of donut charts, one per feature.

chart_grouped_bar(df[, colors, title, ...])

Create a grouped (or stacked) bar chart for multi-feature zonal stats.

chart_multi_feature_timeseries(per_feature_dfs)

Create a subplot figure with one time-series chart per feature.

chart_sankey_d3(sankey_df, class_names, ...)

Create a D3 Sankey diagram directly from transition data — no Plotly.

chart_scatter(df, x_band, y_band[, ...])

Create a scatter plot of two bands across features.

chart_time_series(df[, colors, chart_type, ...])

Create a Plotly time series chart from a zonal stats DataFrame.

detect_geometry_type(geometry)

Determine whether the input geometry represents a single region or multiple.

get_obj_info(ee_obj[, band_names])

Detect the type of a GEE object and read its thematic class metadata.

parse_continuous_results(raw_dict, obj_info, ...)

Parse continuous (mean/median/etc.) reduction results into a DataFrame.

parse_thematic_results(raw_dict, obj_info, ...)

Parse frequency histogram reduction results into a DataFrame with class names as columns.

prepare_for_reduction(ee_obj, obj_info[, ...])

Prepare a GEE object for reduction by stacking an ImageCollection into a single multi-band image.

prepare_sankey_data(ee_collection, ...[, ...])

Build a Sankey diagram dataset from class transitions across time periods.

reduce_region(image, geometry, reducer[, ...])

Run image.reduceRegion with sensible defaults.

reduce_regions(image, features, reducer[, ...])

Run image.reduceRegions and return the result as a DataFrame.

sankey_iframe(sankey_html[, width, height])

Wrap sankey D3 HTML in an iframe for Jupyter notebook display.

sankey_to_html(fig[, full_html, ...])

Return sankey HTML, accepting either a raw HTML string or legacy Plotly figure.

save_chart_html(fig, filename[, ...])

Save a chart to an HTML file.

summarize_and_chart(ee_obj, geometry[, ...])

Run zonal statistics and produce a chart in one call.

zonal_stats(ee_obj, geometry[, band_names, ...])

Compute zonal statistics for a GEE Image or ImageCollection over a geometry.