geeViz.geeView¶
View GEE objects using Python
geeViz.geeView is the core module for managing GEE objects on the geeViz mapper object. geeViz instantiates an instance of the mapper class as Map by default. Layers can be added to the map using Map.addLayer or Map.addTimeLapse and then viewed using the Map.view method.
Functions
|
[255,255,255] -> "#FFFFFF" |
|
Get root domain for a given url |
|
Remove trailing '....' in generated access token |
|
Takes in a list of RGB sub-lists and returns dictionary of colors in RGB and hex form for use in a graphing function defined later on |
|
Take a palette and a set of min and max stretch values to get a 1:1 value to color hex list |
|
Return (red, green, blue) for the color given as #rrggbb. |
|
See if a given port number is currently active |
Check if inside Jupyter shell |
|
|
returns a gradient list of (n) colors between two hex colors. |
|
returns a list of colors forming linear gradients between all sequential pairs of colors. |
Get a refresh token from currently authenticated ee instance |
|
|
Thin pointer to |
|
Start the in-process threaded geeViz web server, rooted at the geeViz package directory. |
|
Get a refresh token from service account key file credentials |
|
Sets the project id of an instance of ee |
|
Tries to find the current Google Cloud Platform project id and set it |
Classes
|
Primary geeViz map setup and manipulation object. |
- geeViz.geeView.setProject(id)[source]¶
Sets the project id of an instance of ee
- Parameters:
id (str) – Google Cloud Platform project id to use
- geeViz.geeView.simpleSetProject(overwrite=False, verbose=False)[source]¶
Tries to find the current Google Cloud Platform project id and set it
Args: overwrite (bool, optional): Whether or not to overwrite a cached project ID file
- geeViz.geeView.robustInitializer(verbose: bool = False)[source]¶
Thin pointer to
geeViz.eeAuth.robust_init— kept here for backwards compatibility with scripts that imported it fromgeeViz.geeViewdirectly.The full decision tree (eeAuth proxy → EE refresh token → ADC fallback with explicit warning → interactive
ee.Authenticate(force=True)) lives ingeeViz.eeAuth.eeCreds.EECreds.robust_initso it’s usable from any geeViz entry point, not just module import.
- geeViz.geeView.color_dict_maker(gradient: list[list[int]]) dict[source]¶
Takes in a list of RGB sub-lists and returns dictionary of colors in RGB and hex form for use in a graphing function defined later on
- geeViz.geeView.hex_to_rgb(value: str) tuple[source]¶
Return (red, green, blue) for the color given as #rrggbb.
- geeViz.geeView.linear_gradient(start_hex: str, finish_hex: str = '#FFFFFF', n: int = 10) dict[source]¶
returns a gradient list of (n) colors between two hex colors. start_hex and finish_hex should be the full six-digit color string, inlcuding the number sign (“#FFFFFF”)
- geeViz.geeView.polylinear_gradient(colors: list[str], n: int)[source]¶
returns a list of colors forming linear gradients between all sequential pairs of colors. “n” specifies the total number of desired output colors
- geeViz.geeView.get_poly_gradient_ct(palette: list[str], min: int, max: int) list[str][source]¶
Take a palette and a set of min and max stretch values to get a 1:1 value to color hex list
- Parameters:
palette (list) – A list of hex code colors that will be interpolated
min (int) – The min value for the stretch
max (int) – The max value for the stretch
- Returns:
A list of linearly interpolated hex codes where there is 1:1 color to value from min-max (inclusive)
- Return type:
list
>>> import geeViz.geeView as gv >>> viz = {"palette": ["#FFFF00", "00F", "0FF", "FF0000"], "min": 1, "max": 20} >>> color_ramp = gv.get_poly_gradient_ct(viz["palette"], viz["min"], viz["max"]) >>> print("Color ramp:", color_ramp)
- geeViz.geeView.is_notebook()[source]¶
Check if inside Jupyter shell
- Returns:
Whether inside Jupyter shell or not
- Return type:
bool
- geeViz.geeView.cleanAccessToken(accessToken)[source]¶
Remove trailing ‘….’ in generated access token
- Parameters:
accessToken (str) – Raw access token
- Returns:
Given access token without trailing ‘….’
- Return type:
str
- geeViz.geeView.baseDomain(url)[source]¶
Get root domain for a given url
- Parameters:
url (str) – URL to find the base domain of
- Returns:
domain of given URL
- Return type:
str
- geeViz.geeView.refreshToken()[source]¶
Get a refresh token from currently authenticated ee instance
- Returns:
temporary access token
- Return type:
str
- geeViz.geeView.serviceAccountToken(service_key_file_path)[source]¶
Get a refresh token from service account key file credentials
- Returns:
temporary access token
- Return type:
str
- geeViz.geeView.run_local_server(port: int = 8001)[source]¶
Start the in-process threaded geeViz web server, rooted at the geeViz package directory.
The function is idempotent: if a server is already running on port, it returns the existing port number without restarting. If port is held by an unrelated process (or a stale subprocess from an older geeViz version that we can’t kill), we transparently auto-pick a free port and return the actual port that ended up bound.
- Parameters:
port (int) – Preferred port number. If unavailable, a free port is auto-selected.
- Returns:
- The port number the server is actually bound to. Callers should
use this (not the originally-requested port) when building URLs.
- Return type:
int
- geeViz.geeView.isPortActive(port: int = 8001)[source]¶
See if a given port number is currently active
- Parameters:
port (int) – Port number to check status of
- Returns:
Whether or not the port is already active
- Return type:
bool
- class geeViz.geeView.mapper(port: int = 8001)[source]¶
Bases:
objectPrimary geeViz map setup and manipulation object.
The mapper builds up a list of GEE layers and map commands (addLayer, addTimeLapse, turnOnInspector, setCenter, etc.) and then launches the interactive geeView web viewer via view().
Rendering flow (as of geeViz 2026.3.3)
Map.view() writes the per-session runGeeViz.js to its canonical disk location (geeView/src/gee/gee-run/) and opens geeView/index.html directly:
Plain Python / scripts — opened via a file:// URL with the access token passed as a query string. No HTTP server needed.
Notebooks (VS Code, Jupyter) — displayed inline via an IFrame(src=”http://localhost:<port>/geeView/…”) backed by an in-process threaded http.server (daemon thread, no subprocess). VS Code’s webview blocks file:// in iframes, so a real HTTP origin is required for inline display. The server auto-picks a free port if the preferred one (default 8001) is held.
Colab / Vertex AI Workbench — uses platform-specific proxy URLs via google.colab.kernel.proxyPort() or self.proxy_url.
The buildgeeViz.py build script patches lcms-viewer.min.js so the viewer’s runtime loadGEELibraries() call uses document.createElement(‘script’) instead of $.getScript() (which is jQuery XHR — blocked by Chrome under file://). It also strips the dead require(…) fallback from changeDetectionLib.js.
Key methods
view(open_browser=None, open_iframe=None, iframe_height=525) — launch the viewer
addLayer / addTimeLapse / addSelectLayer / turnOnInspector / turnOnAutoAreaCharting / setCenter / centerObject / clearMap
refresh() — re-run the last view() with a fresh token
- Parameters:
port (int, default 8001) – Port for the in-process http.server used for notebook iframe display. Auto-picks a free port if unavailable.
- port¶
Port for the in-process http.server used for notebook iframe display. Auto-picks a free port if unavailable.
- Type:
int, default 8001
- proxy_url¶
Vertex AI Workbench proxy URL used when view() runs inside a Workbench notebook. Auto-prompted on first call if unset; set manually in advance (e.g. Map.proxy_url = “https://code-dot-region.notebooks.googleusercontent.com/”) to skip the prompt. Ignored outside Workbench.
- Type:
str, default None
- refreshTokenPath¶
Path to the Earth Engine refresh token credentials file used to mint fresh access tokens on each view() call.
- Type:
str, default ee.oauth.get_credentials_path()
- serviceKeyPath¶
Path to a service account key JSON. If provided, it will be used for authentication inside geeView instead of the refresh token — useful for headless deployments (Cloud Run, scheduled jobs) where no user refresh token is available.
- Type:
str, default None
- project¶
Google Cloud project id used for Earth Engine. geeViz tries to resolve this automatically from ee.Initialize(project=…); set it manually if Map.view() logs project=None.
- Type:
str, default ee.data._get_state().cloud_api_user_project
- turnOffLayersWhenTimeLapseIsOn¶
Whether all other layers should be turned off when a time lapse is turned on. Default is True to avoid confusing layer-order rendering when time lapses and non-time lapses are visible at the same time. Set to False if you want them visible simultaneously.
- Type:
bool, default True
- showToolTipModal¶
Whether to show the tooltip modal when the map is loaded.
- Type:
bool, default False
- property port: int¶
- addLayer(image: Image | ImageCollection | Geometry | Feature | FeatureCollection, viz: dict = {}, name: str | None = None, visible: bool = True)[source]¶
Adds GEE object to the mapper object that will then be added to the map user interface with a view call.
- Parameters:
image (ImageCollection, Image, Feature, FeatureCollection, Geometry) – ee object to add to the map UI.
viz (dict) –
Primary set of parameters for map visualization, querying, charting, etc. In addition to the parameters supported by the addLayer function in the GEE Code Editor, there are several additional parameters available to help facilitate legend generation, querying, and area summaries. The accepted keys are:
- {
“min” (int, list, or comma-separated numbers): One numeric value or one per band to map onto 00.,
”max” (int, list, or comma-separated numbers): One numeric value or one per band to map onto FF,
”gain” (int, list, or comma-separated numbers): One numeric value or one per band to map onto 00-FF.,
”bias” (int, list, or comma-separated numbers): One numeric value or one per band to map onto 00-FF.,
”gamma” (int, list, or comma-separated numbers): Gamma correction factor. One numeric value or one per band.,
”palette” (str, list, or comma-separated strings): List of CSS-style color strings (single-band previews only).,
”opacity” (float): a number between 0 and 1 for initially set opacity.,
”layerType” (str, one of geeImage, geeImageCollection, geeVector, geeVectorImage, geoJSONVector): Optional parameter. For vector data (“featureCollection”, “feature”, or “geometry”), you can spcify “geeVector” if you would like to force the vector to be an actual vector object on the client. This can be slow if the ee object is large and/or complex. Otherwise, any “featureCollection”, “feature”, or “geometry” will default to “geeVectorImage” where the vector is rasterized on-the-fly for map rendering. Any querying of the vector will query the underlying vector data though. To add a geojson vector as json, just add the json as the image parameter.,
”reducer” (Reducer, default ‘ee.Reducer.lastNonNull()’): If an ImageCollection is provided, how to reduce it to create the layer that is shown on the map. Defaults to ee.Reducer.lastNonNull(),
”autoViz” (bool): Whether to take image bandName_class_values, bandName_class_names, bandName_class_palette properties to visualize, create a legend (populates classLegendDict), and apply class names to any query functions (populates queryDict),
”includeClassValues” (bool, default True): Whether to include the numeric value of each class in the legend when “autoViz”:True.
”canQuery” (bool, default True): Whether a layer can be queried when visible.,
”addToLegend” (bool, default True): Whether geeViz should try to create a legend for this layer. Sometimes setting it to False is useful for continuous multi-band inputs.,
”classLegendDict” (dict): A dictionary with a key:value of the name:color(hex) to include in legend. This is auto-populated when autoViz : True,
”queryDict” (dict): A dictionary with a key:value of the queried number:label to include if queried numeric values have corresponding label names. This is auto-populated when autoViz : True,
”queryParams” (dict, optional): Dictionary of additional parameters for querying visible map layers:
- {
“palette” (list, or comma-separated strings): List of hex codes for colors for charts. This is especially useful when bandName_class_values, bandName_class_names, bandName_class_palette properties are not available, but there is a desired set of colors for each band to have on the chart.,
”yLabel” (str, optional): Y axis label for query charts. This is useful when bandName_class_values, bandName_class_names, bandName_class_palette properties are not available, but there is a desired label for the Y axis.
}
”legendLabelLeftBefore” (str) : Label for continuous legend on the left before the numeric component,
”legendLabelLeftAfter” (str) : Label for continuous legend on the left after the numeric component,
”legendLabelRightBefore” (str) : Label for continuous legend on the right before the numeric component,
”legendLabelRightAfter” (str) : Label for continuous legend on the right after the numeric component,
”canAreaChart” (bool): whether to include this layer for area charting. If the layer is complex, area charting can be quite slow,
- ”areaChartParams” (dict, optional): Parameters for the interactive area charting
in the geeView map viewer. Passed to the viewer’s JS
areaChart.addLayer(). All keys are optional.Reducer & spatial resolution:
"reducer"(ee.Reducer): Reducer for zonal stats. Defaultee.Reducer.frequencyHistogram()for thematic data (whenbandName_class_values/names/paletteproperties exist),ee.Reducer.mean()otherwise."crs"(str, default"EPSG:5070"): CRS for zonal stats."transform"(list, default[30, 0, -2361915, 0, -30, 3177735]): Snap transform for zonal stats."scale"(int, default None): Spatial resolution. Only specify iftransformis None."minZoomSpecifiedScale"(int, default 11): Zoom level below which spatial resolution doubles per zoom step.
Chart type & display:
"line"(bool, default True): Create a line chart."sankey"(bool, default False): Create Sankey transition charts. Only for thematicee.ImageCollectionwithsystem:time_start."chartType"(str, default"line"for ImageCollection,"bar"for Image): Options:"line","bar","stacked-line","stacked-bar"."steppedLine"(bool, default False): Step interpolation."showGrid"(bool, default True): Show grid lines."rangeSlider"(bool, default False): Show x-axis range slider."autoScale"(bool): Auto-scale chart axes.
Sankey-specific:
"sankeyTransitionPeriods"(list of lists): Years for sankey transitions (e.g.[[1985,1987],[2000,2002],[2020,2022]])."sankeyMinPercentage"(float, default 0.5): Min class % to include in sankey.
Masking / threshold support:
"shouldUnmask"(bool, default False): Include masked pixels in area chart by unmasking before reducing. Use with.selfMask()threshold layers so percentages are relative to total area."unmaskValue"(int/float, default 0): Value to unmask to.
Labels & formatting:
"bandNames"(list or str): Bands to chart. Defaults to all bands orviz["bands"]."dateFormat"(str, default"YYYY"): Date format for x-axis labels."xAxisLabel"(str): Custom x-axis label."yAxisLabel"(str): Custom y-axis label. Defaults to"% Area"for thematic,"Mean"for continuous."xAxisProperty"(str): Property for x-axis values instead of date."xTickDateFormat"(str): Date format for x-axis ticks."hovermode"(str, default"closest"): Options:"closest","x","y","x unified","y unified"."palette"(list or comma-separated str): Hex colors for chart series."chartLabelMaxWidth"(int, default 40): Max chars per line in class labels."chartLabelMaxLength"(int, default 100): Max total chars in class labels."barChartMaxClasses"(int, default 20): Max classes in bar charts."chartPrecision"(int, default 3): Decimal places."chartDecimalProportion"(float, default 0.25): Proportion of total decimal places to show.
Sizing:
"chartWidth"(int): Chart width in pixels."chartHeight"(int): Chart height in pixels."chartTitleFontSize"(int): Title font size."chartLabelFontSize"(int): Label font size."chartAxisTitleFontSize"(int): Axis title font size.
Class overrides (auto-detected from image properties):
"class_names"(dict): Override class names by band."class_values"(dict): Override class values by band."class_palette"(dict): Override class colors by band."class_visibility"(dict): Override class visibility.
}
name (str) – Descriptive name for map layer that will be shown on the map UI
visible (bool, default True) – Whether layer should be visible when map UI loads
>>> import geeViz.geeView as gv >>> Map = gv.Map >>> ee = gv.ee >>> nlcd = ee.ImageCollection("USGS/NLCD_RELEASES/2021_REL/NLCD").select(['landcover']) >>> Map.addLayer(nlcd, {"autoViz": True}, "NLCD Land Cover / Land Use 2021") >>> Map.turnOnInspector() >>> Map.view()
- addTileLayer(url_template: str, name: str = 'Tile Layer', visible: bool = True, opacity: float = 1.0, max_zoom: int = 20)[source]¶
Add an external XYZ tile service (or any URL-templated raster service) to the map without leaving geeViz for Leaflet/Mapbox.
The viewer (lcms-viewer.min.js) already supports tile-URL layers via its
addREST/tileMapServicepaths; this Python entry point wraps that for the standardMap.*API.- Parameters:
url_template (str) – XYZ tile URL with
{x},{y},{z}placeholders. e.g."https://example.com/tiles/{z}/{x}/{y}.png". ArcGIS MapServer/ImageServer tile endpoints fit this template too (substitute appropriately).name (str, optional) – Layer name shown in the layer list.
visible (bool, optional) – Whether the layer is on initially.
opacity (float, optional) – Initial opacity 0-1. Defaults to 1.0.
max_zoom (int, optional) – Maximum zoom level the source serves. Defaults to 20.
Examples
CTrees AGB tiles, displayed alongside an EE layer:
Map.addLayer(my_ee_image, viz, "EE Layer") Map.addTileLayer( "https://viz-assets.ctrees.org/sfi/basemaps/agb_100m/{z}/{x}/{y}.png", name="CTrees AGB (100m)", opacity=0.7, ) Map.centerObject(area, 9) Map.view()
ESRI World Imagery basemap:
Map.addTileLayer( "https://server.arcgisonline.com/ArcGIS/rest/services/" "World_Imagery/MapServer/tile/{z}/{y}/{x}", name="ESRI World Imagery", )
- addDynamicMapService(service_url: str, name: str = 'Dynamic MapService', visible: bool = True, layers: str = '', transparent: bool = True, dpi: int = 96, min_zoom: int = 0, token: str | None = None)[source]¶
Add a dynamic (non-cached) ArcGIS MapServer as a re-rendered overlay. Use this for services whose metadata reports
singleFusedMapCache: false— e.g. FEMA NFHL, USFS Forest Roads, most authoritative government REST services. For CACHED MapServers useaddTileLayeroresriLib.addEsriMapServiceinstead.- Parameters:
service_url (str) – ArcGIS MapServer URL ending in
/MapServer(no/tile/...suffix).name (str, optional) – Layer name shown in the layer list.
visible (bool, optional) – Initial visibility.
layers (str, optional) – ArcGIS
layersparam value —"show:2,3","hide:1", or""for defaults.transparent (bool, optional) – PNG transparency for overlay use. Defaults to True.
dpi (int, optional) – Screen DPI for the export request. 96 is standard; bump to 192 for HiDPI displays.
min_zoom (int, optional) – Below this zoom the overlay isn’t requested (blank tile). Defaults to 0 (always request).
token (str, optional) – ArcGIS auth token appended to every export request.
- addEsriImageService(url_or_result, viz_params=None, name=None, token=None)[source]¶
See
geeViz.esriLib.addEsriImageService. Delegates.
- addEsriMapService(url_or_result, name=None, token=None, viz_params=None)[source]¶
See
geeViz.esriLib.addEsriMapService. Delegates. If the service is dynamic (non-cached), esriLib now falls back toMap.addDynamicMapServiceinternally instead of raising.
- addEsriFeatureService(url_or_result, viz_params=None, name=None, max_features=1000, where='1=1', token=None)[source]¶
See
geeViz.esriLib.addEsriFeatureService. Delegates.
- addEsriService(url_or_result, viz_params=None, name=None, token=None, max_features=1000, where='1=1')[source]¶
See
geeViz.esriLib.addEsriService. Auto-detects the service type from URL / metadata and delegates to the right add-helper.
- addTimeLapse(image: ImageCollection, viz: dict = {}, name: str | None = None, visible: bool = True)[source]¶
Adds GEE ImageCollection object to the mapper object that will then be added as an interactive time lapse in the map user interface with a view call.
- Parameters:
image (ImageCollection) – ee ImageCollecion object to add to the map UI.
viz (dict) –
Primary set of parameters for map visualization, querying, charting, etc. These are largely the same as the addLayer function. Keys unique to addTimeLapse are provided here first. In addition to the parameters supported by the addLayer function in the GEE Code Editor, there are several additional parameters available to help facilitate legend generation, querying, and area summaries. The accepted keys are:
- {
“mosaic” (bool, default False): If an ImageCollection with multiple images per time step is provided, how to reduce it to create the layer that is shown on the map. Uses ee.Reducer.lastNonNull() if True or ee.Reducer.first() if False,
”dateFormat” (str, default “YYYY”): The format of the date to show in the slider. E.g. if your data is annual, generally “YYYY” is best. If it’s monthly, generally “YYYYMM” is best. Daily, generally “YYYYMMdd”…etc.,
”advanceInterval” (str, default ‘year’): How much to advance each frame when creating each individual mosaic. One of ‘year’, ‘month’ ‘week’, ‘day’, ‘hour’, ‘minute’, or ‘second’.
”min” (int, list, or comma-separated numbers): One numeric value or one per band to map onto 00.,
”max” (int, list, or comma-separated numbers): One numeric value or one per band to map onto FF,
”gain” (int, list, or comma-separated numbers): One numeric value or one per band to map onto 00-FF.,
”bias” (int, list, or comma-separated numbers): One numeric value or one per band to map onto 00-FF.,
”gamma” (int, list, or comma-separated numbers): Gamma correction factor. One numeric value or one per band.,
”palette” (str, list, or comma-separated strings): List of CSS-style color strings (single-band previews only).,
”opacity” (float): a number between 0 and 1 for initially set opacity.,
”autoViz” (bool): Whether to take image bandName_class_values, bandName_class_names, bandName_class_palette properties to visualize, create a legend (populates classLegendDict), and apply class names to any query functions (populates queryDict),
”includeClassValues” (bool, default True): Whether to include the numeric value of each class in the legend when “autoViz”:True.
”canQuery” (bool, default True): Whether a layer can be queried when visible.,
”addToLegend” (bool, default True): Whether geeViz should try to create a legend for this layer. Sometimes setting it to False is useful for continuous multi-band inputs.,
”classLegendDict” (dict): A dictionary with a key:value of the name:color(hex) to include in legend. This is auto-populated when autoViz : True,
”queryDict” (dict): A dictionary with a key:value of the queried number:label to include if queried numeric values have corresponding label names. This is auto-populated when autoViz : True,
”queryParams” (dict, optional): Dictionary of additional parameters for querying visible map layers:
- {
“palette” (list, or comma-separated strings): List of hex codes for colors for charts. This is especially useful when bandName_class_values, bandName_class_names, bandName_class_palette properties are not available, but there is a desired set of colors for each band to have on the chart.,
”yLabel” (str, optional): Y axis label for query charts. This is useful when bandName_class_values, bandName_class_names, bandName_class_palette properties are not available, but there is a desired label for the Y axis.
}
”legendLabelLeftBefore” (str) : Label for continuous legend on the left before the numeric component,
”legendLabelLeftAfter” (str) : Label for continuous legend on the left after the numeric component,
”legendLabelRightBefore” (str) : Label for continuous legend on the right before the numeric component,
”legendLabelRightAfter” (str) : Label for continuous legend on the right after the numeric component,
”canAreaChart” (bool): whether to include this layer for area charting. If the layer is complex, area charting can be quite slow,
- ”areaChartParams” (dict, optional): Parameters for the interactive area charting
in the geeView map viewer. Passed to the viewer’s JS
areaChart.addLayer(). All keys are optional.Reducer & spatial resolution:
"reducer"(ee.Reducer): Reducer for zonal stats. Defaultee.Reducer.frequencyHistogram()for thematic data (whenbandName_class_values/names/paletteproperties exist),ee.Reducer.mean()otherwise."crs"(str, default"EPSG:5070"): CRS for zonal stats."transform"(list, default[30, 0, -2361915, 0, -30, 3177735]): Snap transform for zonal stats."scale"(int, default None): Spatial resolution. Only specify iftransformis None."minZoomSpecifiedScale"(int, default 11): Zoom level below which spatial resolution doubles per zoom step.
Chart type & display:
"line"(bool, default True): Create a line chart."sankey"(bool, default False): Create Sankey transition charts. Only for thematicee.ImageCollectionwithsystem:time_start."chartType"(str, default"line"for ImageCollection,"bar"for Image): Options:"line","bar","stacked-line","stacked-bar"."steppedLine"(bool, default False): Step interpolation."showGrid"(bool, default True): Show grid lines."rangeSlider"(bool, default False): Show x-axis range slider."autoScale"(bool): Auto-scale chart axes.
Sankey-specific:
"sankeyTransitionPeriods"(list of lists): Years for sankey transitions (e.g.[[1985,1987],[2000,2002],[2020,2022]])."sankeyMinPercentage"(float, default 0.5): Min class % to include in sankey.
Masking / threshold support:
"shouldUnmask"(bool, default False): Include masked pixels in area chart by unmasking before reducing. Use with.selfMask()threshold layers so percentages are relative to total area."unmaskValue"(int/float, default 0): Value to unmask to.
Labels & formatting:
"bandNames"(list or str): Bands to chart. Defaults to all bands orviz["bands"]."dateFormat"(str, default"YYYY"): Date format for x-axis labels."xAxisLabel"(str): Custom x-axis label."yAxisLabel"(str): Custom y-axis label. Defaults to"% Area"for thematic,"Mean"for continuous."xAxisProperty"(str): Property for x-axis values instead of date."xTickDateFormat"(str): Date format for x-axis ticks."hovermode"(str, default"closest"): Options:"closest","x","y","x unified","y unified"."palette"(list or comma-separated str): Hex colors for chart series."chartLabelMaxWidth"(int, default 40): Max chars per line in class labels."chartLabelMaxLength"(int, default 100): Max total chars in class labels."barChartMaxClasses"(int, default 20): Max classes in bar charts."chartPrecision"(int, default 3): Decimal places."chartDecimalProportion"(float, default 0.25): Proportion of total decimal places to show.
Sizing:
"chartWidth"(int): Chart width in pixels."chartHeight"(int): Chart height in pixels."chartTitleFontSize"(int): Title font size."chartLabelFontSize"(int): Label font size."chartAxisTitleFontSize"(int): Axis title font size.
Class overrides (auto-detected from image properties):
"class_names"(dict): Override class names by band."class_values"(dict): Override class values by band."class_palette"(dict): Override class colors by band."class_visibility"(dict): Override class visibility.
}
name (str) – Descriptive name for map layer that will be shown on the map UI
visible (bool, default True) – Whether layer should be visible when map UI loads
>>> import geeViz.geeView as gv >>> Map = gv.Map >>> ee = gv.ee >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter(ee.Filter.calendarRange(2010, 2023, "year")) >>> Map.addTimeLapse(lcms.select(["Land_Cover"]), {"autoViz": True, "mosaic": True}, "LCMS Land Cover Time Lapse") >>> Map.addTimeLapse(lcms.select(["Change"]), {"autoViz": True, "mosaic": True}, "LCMS Change Time Lapse") >>> Map.addTimeLapse(lcms.select(["Land_Use"]), {"autoViz": True, "mosaic": True}, "LCMS Land Use Time Lapse") >>> Map.turnOnInspector() >>> Map.view()
- addSelectLayer(featureCollection: FeatureCollection, viz: dict = {}, name: str | None = None)[source]¶
Adds GEE featureCollection to the mapper object that will then be added as an interactive selection layer in the map user interface with a view call. This layer will be availble for selecting areas to include in area summary charts.
- Parameters:
featureCollection (FeatureCollection) – ee FeatureCollecion object to add to the map UI as a selectable layer, where each feature is selectable by clicking on it.
viz (dict, optional) –
Primary set of parameters for map visualization and specifying which feature attribute to use as the feature name (selectLayerNameProperty), etc. In addition to the parameters supported by the addLayer function in the GEE Code Editor, there are several additional parameters available to help facilitate legend generation, querying, and area summaries. The accepted keys are:
- {
“strokeColor” (str, default random color): The color of the selection layer on the map,
”strokeWeight” (int, default 3): The thickness of the polygon outlines,
”selectLayerNameProperty” (str, default first feature attribute with “name” in it or “system:index”): The attribute name to show when a user selects a feature.
}
name (str, default None) – Descriptive name for map layer that will be shown on the map UI. Will be auto-populated with Layer N if not specified
>>> import geeViz.geeView as gv >>> Map = gv.Map >>> ee = gv.ee >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms, {"autoViz": True, "canAreaChart": True, "areaChartParams": {"line": True, "sankey": True}}, "LCMS") >>> mtbsBoundaries = ee.FeatureCollection("USFS/GTAC/MTBS/burned_area_boundaries/v1") >>> mtbsBoundaries = mtbsBoundaries.map(lambda f: f.set("system:time_start", f.get("Ig_Date"))) >>> Map.addSelectLayer(mtbsBoundaries, {"strokeColor": "00F", "selectLayerNameProperty": "Incid_Name"}, "MTBS Fire Boundaries") >>> Map.turnOnSelectionAreaCharting() >>> Map.view()
- setCenter(lng: float, lat: float, zoom: int | None = None)[source]¶
Center the map on a specified point and optional zoom on loading
- Parameters:
lng (int or float) – The longitude to center the map on
lat (int or float) – The latitude to center the map on
zoom (int, optional) – If provided, will force the map to zoom to this level after centering it on the provided coordinates. If not provided, the current zoom level will be used.
>>> from geeViz.geeView import * >>> Map.setCenter(-111,41,10) >>> Map.view()
- setZoom(zoom: int)[source]¶
Set the map zoom level
- Parameters:
zoom (int) – The zoom level to set the map to on loading.
>>> from geeViz.geeView import * >>> Map.setZoom(10) >>> Map.view()
- centerObject(feature: Geometry | Feature | FeatureCollection | Image, zoom: int | None = None)[source]¶
Center the map on an object on loading
- Parameters:
feature (Feature, FeatureCollection, or Geometry) – The object to center the map on
zoom (int, optional) – If provided, will force the map to zoom to this level after centering it on the object. If not provided, the highest zoom level that allows the feature to be viewed fully will be used.
>>> from geeViz.geeView import * >>> pt = ee.Geometry.Point([-111, 41]) >>> Map.addLayer(pt.buffer(10), {}, "Plot") >>> Map.centerObject(pt) >>> Map.view()
- export_html(output_path: str, asset_base: str = '/geeView/static', token_placeholder: str = '__GEEVIZ_TOKEN__', token_time_placeholder: str = '__GEEVIZ_TOKEN_TIME__', project_placeholder: str = '__GEEVIZ_PROJECT__', auth_proxy_placeholder: str = '__GEEVIZ_AUTH_PROXY__') str[source]¶
Write a self-contained geeView HTML to output_path.
Differs from
view()in three ways:No HTTP server. This method only writes a file; it does not mint tokens or open a browser. Suitable for chat UIs that serve the HTML themselves (e.g. via blob URL).
Asset paths are absolute under
asset_base(default/geeView/static). The hosting server must mount thegeeView/package directory at that prefix.The access token is a placeholder (default
__GEEVIZ_TOKEN__). The host UI is responsible for string-replacing the placeholder with a fresh access token before serving the HTML to the browser. This decouples token lifetime from artifact storage.
- Parameters:
output_path (str) – Where to write the HTML file.
asset_base (str) – URL prefix where the geeView assets are mounted. Defaults to
/geeView/static.token_placeholder (str) – String to use in place of the access token. The host replaces this at serve time.
token_time_placeholder (str) – String to use in place of the access-token creation time (millis epoch).
project_placeholder (str) – String to use in place of the EE project ID.
- Returns:
Absolute path to the written HTML file.
- Return type:
str
- view(open_browser: bool | None = None, open_iframe: bool | None = None, iframe_height: int = 525)[source]¶
Compile all map objects and commands and start the map viewer.
Starts an in-process threaded HTTP server (daemon thread, no subprocess) serving from the geeViz package directory, then opens the viewer in a browser or inline IFrame depending on the environment:
Scripts / plain Python / agents (MCP, ADK): opens
http://localhost:<port>/geeView/?accessToken=...in the default browser viawebbrowser.open().Notebooks (VS Code, Jupyter): displays an inline
IFrameonly (no browser tab).Google Colab: uses
google.colab.kernel.proxyPort()to get a proxy URL (auto-detected, no user action).Vertex AI Workbench: uses
self.proxy_url(set it once viaMap.proxy_url = "https://..."; prompts on first use if unset).Cloud Run / remote deployments: set
Map.proxy_urlto your service’s public URL, same pattern as Workbench.
When neither
open_browsernoropen_iframeis specified, only one opens: IFrame in notebooks, browser otherwise. If one is explicitly set (e.g.open_browser=True), only that one opens. If one is explicitly disabled (e.g.open_browser=False), the other opens instead. Both can be set toTrueto get both.- Parameters:
open_browser (bool | None) – Open in the default browser. Default
None(auto:Trueoutside notebooks,Falsein notebooks).open_iframe (bool | None) – Display an inline IFrame. Default
None(auto:Truein notebooks,Falseotherwise).iframe_height (int, default 525) – Height of the inline IFrame in pixels.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms, {"autoViz": True, "canAreaChart": True, "areaChartParams": {"line": True, "sankey": True}}, "LCMS") >>> Map.turnOnInspector() >>> Map.view()
- refresh()[source]¶
Re-render the viewer with a freshly minted access token.
The embedded access token expires ~1 hour after view() is called; call Map.refresh() to mint a new one and re-display the iframe (or re-open the browser window, depending on the last view() mode).
- setAuthMode(mode: str | None)[source]¶
Set the eeAuth mode
Map.view()uses when it starts / attaches to the eeCreds proxy. Overrides theGEEVIZ_EEAUTH_MODEenv var.- Parameters:
mode –
One of the canonical modes, or
Noneto fall back to the env var / default."attached"— in-process daemon-thread proxy; dies with the script but doesn’t need a separate process. Default on Colab. Silent-fallback on failure — if the proxy can’t start,Map.view()uses the legacy token-in-URL path."attached_strict"— same as"attached"but raises when the proxy can’t start (vs. silent fallback)."detached"— long-lived background subprocess proxy; survives script exit so multi-Map.view()workflows and successive script runs share one proxy. Default on non-Colab."legacy"— no proxy; mint tokens directly into theMap.view()URL. Deprecated — planned for removal.
Legacy aliases (soft-deprecated, still accepted):
"auto"→"attached","proxy"→"attached_strict".
Precedence:
Map.setAuthMode(...)>GEEVIZ_EEAUTH_MODEenv var > default ("attached"on Colab,"detached"elsewhere).>>> Map.setAuthMode("attached") # force in-process proxy >>> Map.view()
- clearMap()[source]¶
Removes all map layers and commands - useful if running geeViz in a notebook and don’t want layers/commands from a prior code block to still be included.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms, {"autoViz": True}, "LCMS") # Layer >>> Map.turnOnInspector() # Command >>> Map.clearMap() # Clear map layer and commands >>> Map.view()
- clear()¶
Removes all map layers and commands - useful if running geeViz in a notebook and don’t want layers/commands from a prior code block to still be included.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms, {"autoViz": True}, "LCMS") # Layer >>> Map.turnOnInspector() # Command >>> Map.clearMap() # Clear map layer and commands >>> Map.view()
- clearMapLayers()[source]¶
Removes all map layers - useful if running geeViz in a notebook and don’t want layers from a prior code block to still be included, but want commands to remain.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms, {"autoViz": True}, "LCMS") # Layer - this will be removed >>> Map.turnOnInspector() # Command - this will remain (even though there will be no layers to query) >>> Map.clearMapLayers() # Clear map layer only and leave commands >>> Map.view()
- clearMapCommands()[source]¶
Removes all map commands - useful if running geeViz in a notebook and don’t want commands from a prior code block to still be included, but want layers to remain.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms, {"autoViz": True}, "LCMS") # Layer >>> Map.turnOnInspector() # Command - this will be removed >>> Map.clearMapCommands() # Clear map comands only and leave layers >>> Map.view()
- exportLayerJson(filename: str | None = None, output_dir: str | None = None)[source]¶
Bundle all currently-added layers into a JSON file suitable for a custom HTML dashboard.
Mirrors the input-type handling of
testLayers()andpreviewMap(): vectors (Geometry, Feature, FeatureCollection) are wrapped/styled via_style_vector(), ImageCollections are collapsed with.mosaic(), andee.Elementresults fromcopyPropertiesare coerced toee.Imageupstream byaddLayer(). The result of these conversions is then serialized — a downstream/api/dashboard/urlsendpoint deserializes and callsgetMapIdon each entry to mint fresh tile URLs on every page load.- Parameters:
filename (str, optional) – Output filename (saved under
output_dir). Must end with.json. Defaults to"dashboard_layers.json".output_dir (str, optional) – Override the directory to write into. Defaults to the per-session
generated_outputsdirectory used by the rest of the artifact pipeline.
- Returns:
{"path": <abs_path>, "layer_names": [...], "layer_count": N, "skipped": [...], "warnings": [...]}.- Return type:
dict
- Notes on skipped layer types:
dict/ GeoJSON layers — no EE object to re-mint; skipped with a warning.Tile-URL layers (added via
addTileLayer()) — already have a static URL; included with"static_url"key instead of"serialized".
- testLayers()[source]¶
Validate all map layers by requesting a map tile ID from Earth Engine in parallel.
Calls
getMapId(viz)on every ee object added viaaddLayeroraddTimeLapse. This catches bad band names, invalid viz params, missing properties, and computation errors – without launching a browser. Runs all requests in parallel viaThreadPoolExecutor.When
autoViz: Trueis set in a layer’s viz params, the method also validates that the image carries the class properties the viewer expects:<bandName>_class_values,<bandName>_class_names, and<bandName>_class_palettefor at least one band.- Returns:
Structure:
{ "pass": bool, # True only if every layer has status "ok" "layers": [ { "name": str, "status": "ok" | "error", "error": str | None, "warnings": list[str] | None # present only when non-empty }, ... ] }
Error vs warning distinction:
Error (
status="error"):autoViz: Truebut no band has any matching class properties, so the viewer will break. Also raised when class properties exist but are keyed to band names that don’t exist on the image (orphaned properties).Warning (
status="ok"withwarnings): A band has partial class properties (e.g._class_valuesis present but_class_paletteis missing). Rendering may be incorrect.
- Return type:
dict
Example
>>> Map.clearMap() >>> Map.addLayer(ee.Image(1), {}, "Valid") >>> Map.addLayer(ee.Image(1).select("nonexistent"), {}, "Bad Band") >>> result = Map.testLayers() >>> result["pass"] False
- previewMap(grid_size=3, zoom=None)[source]¶
Fetch a small grid of map tiles for each layer and return as a dict.
This gives the LLM a quick visual preview of each map layer without launching a browser. Uses
getMapId+tile_fetcher.fetch_tileto grab tiles around the current map center, then stitches them with Pillow into a single PNG per layer.- Parameters:
grid_size (int) – Number of tiles per side (e.g. 3 = 3x3 = 9 tiles). Default 3, producing a 768x768 px image per layer.
zoom (int, optional) – Zoom level for tiles. If None, uses the zoom from the last
setCenter/setZoomcall, or auto-calculates fromcenterObjectbounds. Falls back to 8.
- Returns:
{"layers": {layer_name: png_bytes, ...}, "center": [lng, lat], "zoom": int}Each value in
layersis raw PNG bytes of the stitched tile grid. Layers that fail to render are included with aNonevalue.
- Return type:
dict
- testView(width=1280, height=900, wait_seconds=12)[source]¶
Capture a screenshot of the map via headless Chrome CDP and check for tile errors.
This is a slower but more thorough test than
testLayers— it renders the full map viewer in a headless browser and captures JS console errors and HTTP tile failures. UsetestLayersfor fast validation; usetestViewwhen you need a visual screenshot or want to catch client-side rendering issues.- Parameters:
width (int) – Viewport width in pixels.
height (int) – Viewport height in pixels.
wait_seconds (int) – Max seconds to wait for tiles to load.
- Returns:
{"screenshot_path": str, "tile_errors": list, "console_messages": list}- Return type:
dict
- setMapTitle(title)[source]¶
Set the title that appears in the left sidebar header and the page title
- Parameters:
title (str, default geeViz Data Explorer) – The title to appear in the header on the left sidebar as well as the title of the viewer webpage.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms, {"autoViz": True}, "LCMS") >>> Map.turnOnInspector() >>> Map.setMapTitle("<h2>A Custom Title!!!</h2>") # Set custom map title >>> Map.view()
- setTitle(title)[source]¶
Redundant function for setMapTitle. Set the title that appears in the left sidebar header and the page title
- Parameters:
title (str, default geeViz Data Explorer) – The title to appear in the header on the left sidebar as well as the title of the viewer webpage.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms, {"autoViz": True}, "LCMS") >>> Map.turnOnInspector() >>> Map.setMapTitle("<h2>A Custom Title!!!</h2>") # Set custom map title >>> Map.view()
- setQueryCRS(crs: str)[source]¶
The coordinate reference system string to query layers with
- Parameters:
(str (crs) – 5070”): Which projection (CRS) to use for querying map layers.
"EPSG (default) – 5070”): Which projection (CRS) to use for querying map layers.
>>> import geeViz.getImagesLib as gil >>> from geeViz.geeView import * >>> crs = gil.common_projections["NLCD_AK"]["crs"] >>> transform = gil.common_projections["NLCD_AK"]["transform"] >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="SEAK"') >>> Map.addLayer(lcms, {"autoViz": True}, "LCMS") >>> Map.turnOnInspector() >>> Map.setQueryCRS(crs) >>> Map.setQueryTransform(transform) >>> Map.setCenter(-144.36390353, 60.20479529215, 8) >>> Map.view()
- setQueryScale(scale: int)[source]¶
What scale to query map layers with. Will also update the size of the box drawn on the map query layers are queried.
- Parameters:
scale (int, default None) – The spatial resolution to use for querying map layers in meters. If set, the query transform will be set to None in the map viewer.
>>> import geeViz.getImagesLib as gil >>> from geeViz.geeView import * >>> s2s = gil.superSimpleGetS2(ee.Geometry.Point([-107.61, 37.85]), "2024-01-01", "2024-12-31", 190, 250) >>> projection = s2s.first().select(["nir"]).projection().getInfo() >>> Map.addLayer(s2s.median(), gil.vizParamsFalse10k, "Sentinel-2 Composite") >>> Map.turnOnInspector() >>> Map.setQueryCRS(projection["crs"]) >>> Map.setQueryScale(projection["transform"][0]) >>> Map.centerObject(s2s.first()) >>> Map.view()
- setQueryTransform(transform: list[int])[source]¶
What transform to query map layers with. Will also update the size of the box drawn on the map query layers are queried.
- Parameters:
transform (list, default [30, 0, -2361915, 0, -30, 3177735]) – The snap to grid to use for querying layers on the map. If set, the query scale will be set to None in the map viewer.
>>> import geeViz.getImagesLib as gil >>> from geeViz.geeView import * >>> s2s = gil.superSimpleGetS2(ee.Geometry.Point([-107.61, 37.85]), "2024-01-01", "2024-12-31", 190, 250) >>> projection = s2s.first().select(["nir"]).projection().getInfo() >>> Map.addLayer(s2s.median(), gil.vizParamsFalse10k, "Sentinel-2 Composite") >>> Map.turnOnInspector() >>> Map.setQueryCRS(projection["crs"]) >>> Map.setQueryTransform(projection["transform"]) >>> Map.centerObject(s2s.first()) >>> Map.view()
- setQueryPrecision(chartPrecision: int = 3, chartDecimalProportion: float = 0.25)[source]¶
What level of precision to show for queried layers. This avoids showing too many digits after the decimal.
- Parameters:
chartPrecision (int, default 3) – Will show the larger of chartPrecision decimal places or ceiling(chartDecimalProportion * total decimal places). E.g. if the number is 1.12345678, 0.25 of 8 decimal places is 2, so 3 will be used and yield 1.123.
chartDecimalProportion (float, default 0.25) – Will show the larger of chartPrecision decimal places or chartDecimalProportion * total decimal places. E.g. if the number is 1.1234567891234, ceiling(0.25 of 13) decimal places is 4, so 4 will be used and yield 1.1235.
>>> import geeViz.getImagesLib as gil >>> from geeViz.geeView import * >>> s2s = gil.superSimpleGetS2(ee.Geometry.Point([-107.61, 37.85]), "2024-01-01", "2024-12-31", 190, 250).select(["blue", "green", "red", "nir", "swir1", "swir2"]) >>> projection = s2s.first().select(["nir"]).projection().getInfo() >>> s2s = s2s.map(lambda img: ee.Image(img).divide(10000).set("system:time_start",img.date().millis())) >>> Map.addLayer(s2s, gil.vizParamsFalse, "Sentinel-2 Images") >>> Map.addLayer(s2s.median(), gil.vizParamsFalse, "Sentinel-2 Composite") >>> Map.turnOnInspector() >>> Map.setQueryCRS(projection["crs"]) >>> Map.setQueryTransform(projection["transform"]) >>> Map.setQueryPrecision(chartPrecision=2, chartDecimalProportion=0.1) >>> Map.centerObject(s2s.first()) >>> Map.view()
- setQueryDateFormat(defaultQueryDateFormat: str = 'YYYY-MM-dd')[source]¶
Set the date format to be used for any dates when querying.
- Parameters:
defaultQueryDateFormat (str, default "YYYY-MM-dd") – The date format string to use for query outputs with dates. To simplify date outputs, “YYYY” is often used instead of the default.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([1]), {"autoViz": True}, "LCMS Land Cover") >>> Map.addLayer(lcms.select([0]), {"autoViz": True}, "LCMS Change") >>> Map.turnOnInspector() >>> Map.setQueryDateFormat("YYYY") >>> Map.view()
- setQueryBoxColor(color: str)[source]¶
Set the color of the query box to something other than yellow
- Parameters:
color (str, default "FFFF00") – Set the default query box color shown on the map by providing a hex color.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([1]), {"autoViz": True}, "LCMS Land Cover") >>> Map.turnOnInspector() >>> Map.setQueryBoxColor("0FF") >>> Map.view()
- setQueryWindowMode(mode)[source]¶
Set where inspector query results are rendered.
Low-level setter — prefer
setQueryToInfoWindow()orsetQueryToSidePane()unless you know the exact mode string the frontend expects.- Parameters:
mode (str) – One of
"infoWindow"(popup over the map) or"sidePane"(dedicated results panel).
- setQueryToInfoWindow()[source]¶
Set the location of query outputs to an info window popup over the map
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([1]), {"autoViz": True}, "LCMS Land Cover") >>> Map.turnOnInspector() >>> Map.setQueryToInfoWindow() >>> Map.view()
- setQueryToSidePane()[source]¶
Set the location of query outputs to the right sidebar above the legend
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([1]), {"autoViz": True}, "LCMS Land Cover") >>> Map.turnOnInspector() >>> Map.setQueryToSidePane() >>> Map.view()
- turnOnInspector()[source]¶
Turn on the query inspector tool upon map loading. This is used frequently so map layers can be queried as soon as the map viewer loads.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([1]), {"autoViz": True}, "LCMS Land Cover") >>> Map.turnOnInspector() >>> Map.view()
- turnOnAutoAreaCharting()[source]¶
Turn on automatic area charting upon map loading. This will automatically update charts by summarizing any visible layers with “canAreaChart” : True any time the map finishes panning or zooming.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([1]), {"autoViz": True,'canAreaChart':True}, "LCMS Land Cover") >>> Map.turnOnAutoAreaCharting() >>> Map.view()
- turnOnUserDefinedAreaCharting()[source]¶
Turn on area charting by a user defined area upon map loading. This will update charts by summarizing any visible layers with “canAreaChart” : True when the user draws an area to summarize and hits the Chart Selected Areas button in the user interface under Area Tools -> User-Defined Area.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([1]), {"autoViz": True,'canAreaChart':True}, "LCMS Land Cover") >>> Map.turnOnUserDefinedAreaCharting() >>> Map.view()
- turnOnSelectionAreaCharting()[source]¶
Turn on area charting by a user selected area upon map loading. This will update charts by summarizing any visible layers with “canAreaChart” : True when the user selects selection areas to summarize and hits the Chart Selected Areas button in the user interface under Area Tools -> Select an Area on Map.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([1]), {"autoViz": True,'canAreaChart':True}, "LCMS Land Cover") >>> mtbsBoundaries = ee.FeatureCollection("USFS/GTAC/MTBS/burned_area_boundaries/v1") >>> mtbsBoundaries = mtbsBoundaries.map(lambda f: f.set("system:time_start", f.get("Ig_Date"))) >>> Map.addSelectLayer(mtbsBoundaries, {"strokeColor": "00F", "selectLayerNameProperty": "Incid_Name"}, "MTBS Fire Boundaries") >>> Map.turnOnSelectionAreaCharting() >>> Map.view()
- addAreaChartLayer(image: Image | ImageCollection, params: dict = {}, name: str | None = None, shouldChart: bool = True)[source]¶
Use this method to add a layer for area charting that you do not want as a map layer as well. Once you add all area chart layers to the map, you can turn them on using the Map.populateAreaChartLayerSelect method. This will create a selection menu inside the Area Tools -> Area Tools Parameters menu. You can then turn layers to include in any area charts on and off from that menu.
- Parameters:
image (ImageCollection, Image) – ee Image or ImageCollection to add to include in area charting.
params (dict) –
Primary set of parameters for charting setup (colors, chart types, etc), charting, etc. The accepted keys are:
{
“reducer” (Reducer, default ee.Reducer.mean() if no bandName_class_values, bandName_class_names, bandName_class_palette properties are available. ee.Reducer.frequencyHistogram if those are available or thematic:True (see below)): The reducer used to compute zonal summary statistics.,
”crs” (str, default “EPSG:5070”): the coordinate reference system string to use for are chart zonal stats,
”transform” (list, default [30, 0, -2361915, 0, -30, 3177735]): the transform to snap to for zonal stats,
”scale” (int, default None): The spatial resolution to use for zonal stats. Only specify if transform : None.
”line” (bool, default True): Whether to create a line chart,
”sankey” (bool, default False): Whether to create Sankey charts - only available for thematic (discrete) inputs that have a system:time_start property set for each image,
”chartLabelMaxWidth” (int, default 40): The maximum number of characters, including spaces, allowed in a single line of a chart class label. The class name will be broken at this number of characters, including spaces, to go to the next line,
”chartLabelMaxLength” (int, default 100): The maximum number of characters, including spaces, allowed in a chart class label. Any class name with more characters, including spaces, than this number will be cut off at this number of characters,
”sankeyTransitionPeriods” (list of lists, default None): The years to use as transition periods for sankey charts (e.g. [[1985,1987],[2000,2002],[2020,2022]]). If not provided, users can enter years in the map user interface under Area Tools -> Transition Charting Periods. These will automatically be used for any layers where no sankeyTransitionPeriods were provided. If years are provided, the years in the user interface will not be used for that layer,
”sankeyMinPercentage” (float, default 0.5): The minimum percentage a given class has to be to be shown in the sankey chart,
”thematic” (bool): Whether input has discrete values or not. If True, it forces the reducer to ee.Reducer.frequencyHistogram() even if not specified and even if bandName_class_values, bandName_class_names, bandName_class_palette properties are not available,
”palette” (list, or comma-separated strings): List of hex codes for colors for charts. This is especially useful when bandName_class_values, bandName_class_names, bandName_class_palette properties are not available, but there is a desired set of colors for each band to have on the chart,
”showGrid” (bool, default True): Whether to show the grid lines on the line or bar graph,
”rangeSlider” (bool,default False): Whether to include the x-axis range selector on the bottom of each graph (https://plotly.com/javascript/range-slider/>),
”barChartMaxClasses” (int, default 20): The maximum number of classes to show for image bar charts. Will automatically only show the top bartChartMaxClasses in any image bar chart. Any downloaded csv table will still have all of the class counts,
”minZoomSpecifiedScale” (int, default 11): The map zoom level where any lower zoom level, not including this zoom level, will multiply the spatial resolution used for the zonal stats by 2 for each lower zoom level. E.g. if the minZoomSpecifiedScale is 9 and the scale is 30, any zoom level >= 9 will compute zonal stats at 30m spatial resolution. Then, at zoom level 8, it will be 60m. Zoom level 7 will be 120m, etc,
”chartPrecision” (int, default 3): Used to override the default global precision settings for a specific area charting layer. See setQueryPrecision for setting the global charting precision. When specified, for this specific area charting layer, will show the larger of chartPrecision decimal places or ceiling(chartDecimalProportion * total decimal places). E.g. if the number is 1.12345678, 0.25 of 8 decimal places is 2, so 3 will be used and yield 1.123,
”chartDecimalProportion” (float, default 0.25): Used to override the default global precision settings for a specific area charting layer. See setQueryPrecision for setting the global charting precision. When specified, for this specific area charting layer, will show the larger of chartPrecision decimal places or chartDecimalProportion * total decimal places. E.g. if the number is 1.1234567891234, ceiling(0.25 of 13) decimal places is 4, so 4 will be used and yield 1.1235,
”hovermode” (str, default “closest”): The mode to show hover text in area summary charts. Options include “closest”, “x”, “y”, “x unified”, and “y unified”,
”yAxisLabel” (str, default an appropriate label based on whether data are thematic or continuous): The Y axis label that will be included in charts. Defaults to a unit of % area for thematic and mean for continuous data,
”chartType” (str, default “line” for ee.ImageCollection and “bar” for ee.Image objects): The type of chart to show. Options include “line”, “bar”, “stacked-line”, and “stacked-bar”. This is only used for ee.ImageCollection objects. For ee.Image objects, the chartType is always “bar”.
}
name (str) – Descriptive name for map layer that will be shown on the map UI
shouldChart (bool, optional) – Whether layer should be charted when map UI loads
>>> import geeViz.geeView as gv >>> Map = gv.Map >>> ee = gv.ee >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select(["Change_Raw_Probability.*"]), {"reducer": ee.Reducer.stdDev(), "min": 0, "max": 10}, "LCMS Change Prob") >>> Map.addAreaChartLayer(lcms, {"line": True, "layerType": "ImageCollection"}, "LCMS All Thematic Classes Line", True) >>> Map.addAreaChartLayer(lcms, {"sankey": True}, "LCMS All Thematic Classes Sankey", True) >>> Map.populateAreaChartLayerSelect() >>> Map.turnOnAutoAreaCharting() >>> Map.view()
- populateAreaChartLayerSelect()[source]¶
Once you add all area chart layers to the map, you can turn them on using this method- Map.populateAreaChartLayerSelect. This will create a selection menu inside the Area Tools -> Area Tools Parameters menu. You can then turn layers to include in any area charts on and off from that menu.
>>> import geeViz.geeView as gv >>> Map = gv.Map >>> ee = gv.ee >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select(["Change_Raw_Probability.*"]), {"reducer": ee.Reducer.stdDev(), "min": 0, "max": 10}, "LCMS Change Prob") >>> Map.addAreaChartLayer(lcms, {"line": True, "layerType": "ImageCollection"}, "LCMS All Thematic Classes Line", True) >>> Map.addAreaChartLayer(lcms, {"sankey": True}, "LCMS All Thematic Classes Sankey", True) >>> Map.populateAreaChartLayerSelect() >>> Map.turnOnAutoAreaCharting() >>> Map.view()
- setYLabelMaxLength(maxLength: int)[source]¶
Set the maximum length a Y axis label can have in charts
- Parameters:
maxLength (int, default 30) – Maximum number of characters in a Y axis label.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([1]), {"autoViz": True}, "LCMS Land Cover") >>> Map.setYLabelMaxLength(10) # Double-click on map to inspect area. Change to a larger number and rerun to see how Y labels are impacted >>> Map.turnOnInspector() >>> Map.setCenter(-109.446, 43.620, 12) >>> Map.view()
- setYLabelBreakLength(maxLength: int)[source]¶
Set the maximum length per line a Y axis label can have in charts
- Parameters:
maxLength (int, default 10) – Maximum number of characters in each line of a Y axis label. Will break total characters (setYLabelMaxLength) until maxLines (setYLabelMaxLines) is reached
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([1]), {"autoViz": True}, "LCMS Land Cover") >>> Map.setYLabelBreakLength(5) # Double-click on map to inspect area. Change to a larger number and rerun to see how Y labels are impacted >>> Map.turnOnInspector() >>> Map.setCenter(-109.446, 43.620, 12) >>> Map.view()
- setYLabelMaxLines(maxLines)[source]¶
Set the max number of lines each y-axis label can have.
- Parameters:
maxLines (int, default 5) – The maximum number of lines each y-axis label can have. Will simply exclude any remaining lines.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([1]), {"autoViz": True}, "LCMS Land Cover") >>> Map.setYLabelMaxLines(3) # Double-click on map to inspect area. Change to a larger number and rerun to see how Y labels are impacted >>> Map.turnOnInspector() >>> Map.setCenter(-109.446, 43.620, 12) >>> Map.view()
- setYLabelFontSize(fontSize: int)[source]¶
Set the size of the font on the y-axis labels. Useful when y-axis labels are too large to fit on the chart.
- Parameters:
fontSize (int, default 10) – The font size used on the y-axis labels for query charting.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([1]), {"autoViz": True}, "LCMS Land Cover") >>> Map.setYLabelFontSize(8) # Double-click on map to inspect area. Change to a different number and rerun to see how Y labels are impacted >>> Map.turnOnInspector() >>> Map.setCenter(-109.446, 43.620, 12) >>> Map.view()
- setCanReorderLayers(canReorderLayers: bool)[source]¶
Set whether layers can be reordered by dragging layer user interface objects. By default all non timelapse and non geojson layers can be reordereed by dragging.
- Parameters:
canReorderLayers (bool, default True) – Set whether layers can be reordered by dragging layer user interface objects. By default all non timelapse and non geojson layers can be reordereed by dragging.
>>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([2]), {"autoViz": True}, "LCMS Land Use") >>> Map.addLayer(lcms.select([1]), {"autoViz": True}, "LCMS Land Cover") >>> Map.addLayer(lcms.select([0]), {"autoViz": True}, "LCMS Change") >>> Map.turnOnInspector() >>> Map.setCanReorderLayers(False) # Notice you cannot drag and reorder layers. Change to True and rerun and notice you now can drag layers to reorder >>> Map.setCenter(-109.446, 43.620, 12) >>> Map.view()
- turnOffAllLayers()[source]¶
Turn off all layers added to the mapper object. Typically used in notebooks or iPython when you want to allow existing layers to remain, but want to turn them all off.
>>> #%% >>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([2]), {"autoViz": True}, "LCMS Land Use") >>> Map.addLayer(lcms.select([1]), {"autoViz": True}, "LCMS Land Cover") >>> Map.turnOnInspector() >>> Map.setCenter(-109.446, 43.620, 5) >>> Map.view() >>> #%% >>> Map.turnOffAllLayers() >>> Map.addLayer(lcms.select([0]), {"autoViz": True}, "LCMS Change") >>> Map.view()
- turnOnAllLayers()[source]¶
Turn on all layers added to the mapper object
>>> #%% >>> from geeViz.geeView import * >>> lcms = ee.ImageCollection("USFS/GTAC/LCMS/v2023-9").filter('study_area=="CONUS"') >>> Map.addLayer(lcms.select([2]), {"autoViz": True}, "LCMS Land Use",False) >>> Map.addLayer(lcms.select([1]), {"autoViz": True}, "LCMS Land Cover",False) >>> Map.turnOnInspector() >>> Map.setCenter(-109.446, 43.620, 5) >>> Map.view() >>> #%% >>> Map.turnOnAllLayers() >>> Map.addLayer(lcms.select([0]), {"autoViz": True}, "LCMS Change") >>> Map.view()