CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-geemap

A Python package for interactive geospatial analysis and visualization with Google Earth Engine

Pending
Overview
Eval results
Files

widgets-tools.mddocs/

Interactive Widgets and Tools

Rich collection of interactive widgets for map controls, data inspection, layer management, custom toolbars, and enhanced user interaction within Jupyter notebook environments.

Capabilities

Layer Management Widgets

Interactive widgets for managing map layers, visibility, and properties.

class LayerManager:
    """Interactive layer management widget."""
    
    def __init__(self, map_object) -> None:
        """
        Initialize layer manager.
        
        Args:
            map_object: Map instance to manage layers for
        """

class LayerManagerRow:
    """Individual row in layer manager representing one layer."""
    
    def __init__(self, layer, **kwargs) -> None:
        """
        Initialize layer manager row.
        
        Args:
            layer: Map layer object
            **kwargs: Additional parameters
        """

class LayerEditor:
    """Widget for editing layer properties and visualization parameters."""
    
    def __init__(self, map_object, layer=None, **kwargs) -> None:
        """
        Initialize layer editor.
        
        Args:
            map_object: Map instance
            layer: Layer to edit (optional)
            **kwargs: Additional parameters
        """

Data Inspector

Interactive tools for inspecting and analyzing map data and Earth Engine objects.

class Inspector:
    """Interactive map data inspector widget."""
    
    def __init__(self, map_object, **kwargs) -> None:
        """
        Initialize data inspector.
        
        Args:
            map_object: Map instance to attach inspector to
            **kwargs: Additional parameters
        """

def inspector_gui(m=None, **kwargs) -> widgets.VBox:
    """
    Create inspector GUI widget.
    
    Args:
        m: Map object to inspect
        **kwargs: Additional parameters
        
    Returns:
        Inspector widget container
    """

Basemap Selector

Widget for selecting and switching between different basemap providers and styles.

class BasemapSelector:
    """Interactive basemap selection widget."""
    
    def __init__(self, map_object, **kwargs) -> None:
        """
        Initialize basemap selector.
        
        Args:
            map_object: Map instance
            **kwargs: Additional parameters
        """

Toolbar System

Comprehensive toolbar system with customizable tools and interactive widgets.

class Toolbar:
    """Main toolbar widget with multiple tools."""
    
    def __init__(self, map_object, **kwargs) -> None:
        """
        Initialize toolbar.
        
        Args:
            map_object: Map instance to attach toolbar to
            **kwargs: Additional parameters
        """

class ToolbarItem:
    """Individual toolbar item widget."""
    
    def __init__(
        self,
        widget,
        icon: str = "wrench",
        tooltip: str = "",
        **kwargs
    ) -> None:
        """
        Initialize toolbar item.
        
        Args:
            widget: Widget to include in toolbar
            icon: Font Awesome icon name
            tooltip: Tooltip text
            **kwargs: Additional parameters
        """

def get_tools_dict() -> Dict[str, Dict]:
    """
    Get dictionary of available toolbar tools.
    
    Returns:
        Dictionary mapping tool names to tool configurations
    """

Plotting and Analysis Tools

Interactive tools for Earth Engine data plotting and analysis.

def ee_plot_gui(m=None, **kwargs) -> widgets.VBox:
    """
    Create Earth Engine plotting GUI.
    
    Args:
        m: Map object for plotting
        **kwargs: Additional parameters
        
    Returns:
        Plotting widget container
    """

def tool_template(**kwargs) -> widgets.VBox:
    """
    Generic tool template for creating custom tools.
    
    Args:
        **kwargs: Tool configuration parameters
        
    Returns:
        Tool widget container
    """

def tool_header_template(
    title: str = "Tool",
    description: str = "",
    **kwargs
) -> widgets.VBox:
    """
    Create tool header template.
    
    Args:
        title: Tool title
        description: Tool description
        **kwargs: Additional parameters
        
    Returns:
        Header widget
    """

Data Collection and Conversion Tools

Interactive tools for collecting samples and converting between data formats.

def collect_samples(**kwargs) -> widgets.VBox:
    """
    Create sample collection tool.
    
    Args:
        **kwargs: Tool parameters
        
    Returns:
        Sample collection widget
    """

def convert_js2py(**kwargs) -> widgets.VBox:
    """
    Create JavaScript to Python conversion tool.
    
    Args:
        **kwargs: Conversion parameters
        
    Returns:
        Conversion tool widget
    """

def open_data_widget(**kwargs) -> widgets.VBox:
    """
    Create open data exploration widget.
    
    Args:
        **kwargs: Widget parameters
        
    Returns:
        Data exploration widget
    """

Legend and Colorbar Widgets

Interactive widgets for displaying and managing map legends and colorbars.

class Legend:
    """Interactive legend widget for maps."""
    
    def __init__(
        self,
        title: str = "Legend",
        legend_dict: Dict = None,
        keys: List[str] = None,
        colors: List[str] = None,
        position: str = "bottomright",
        **kwargs
    ) -> None:
        """
        Initialize legend widget.
        
        Args:
            title: Legend title
            legend_dict: Legend configuration dictionary
            keys: Legend item labels
            colors: Legend item colors
            position: Legend position on map
            **kwargs: Additional parameters
        """

class Colorbar:
    """Interactive colorbar widget."""
    
    def __init__(
        self,
        vis_params: Dict = None,
        cmap: str = "gray",
        discrete: bool = False,
        label: str = None,
        orientation: str = "horizontal",
        position: str = "bottomright",
        **kwargs
    ) -> None:
        """
        Initialize colorbar widget.
        
        Args:
            vis_params: Visualization parameters
            cmap: Colormap name
            discrete: Use discrete colors
            label: Colorbar label
            orientation: Colorbar orientation
            position: Colorbar position on map
            **kwargs: Additional parameters
        """

Theme and Styling

Widget theming and styling utilities for consistent appearance.

class Theme:
    """Widget theme configuration."""
    
    def __init__(
        self,
        primary_color: str = "#3388ff",
        secondary_color: str = "#ffffff",
        **kwargs
    ) -> None:
        """
        Initialize theme.
        
        Args:
            primary_color: Primary theme color
            secondary_color: Secondary theme color
            **kwargs: Additional theme parameters
        """

class TypedTuple:
    """Typed tuple container for widget data."""
    
    def __init__(self, items: List = None, **kwargs) -> None:
        """
        Initialize typed tuple.
        
        Args:
            items: List of items
            **kwargs: Additional parameters
        """

Advanced Widget Utilities

Utilities for widget management and CSS styling in notebook environments.

def _set_css_in_cell_output(css_text: str) -> None:
    """
    Set CSS styling in notebook cell output.
    
    Args:
        css_text: CSS styling text
    """

Usage Examples

Layer Management

import geemap

# Create map
m = geemap.Map()

# Add some layers
m.add_basemap('OpenStreetMap')
m.addLayer(ee.Image('USGS/SRTMGL1_003'), {'min': 0, 'max': 4000}, 'Elevation')

# Create layer manager
layer_manager = geemap.LayerManager(m)

# Display layer manager
layer_manager

Data Inspector

# Create inspector for interactive data exploration
inspector = geemap.Inspector(m)

# Or use the GUI version
inspector_gui = geemap.inspector_gui(m)
inspector_gui

Custom Toolbar

# Create custom toolbar
toolbar = geemap.Toolbar(m)

# Add custom tool
def custom_tool_function():
    print("Custom tool activated!")

custom_item = geemap.ToolbarItem(
    widget=custom_tool_function,
    icon="cog",
    tooltip="Custom Tool"
)

# Get available tools
tools = geemap.get_tools_dict()
print("Available tools:", list(tools.keys()))

Legend Creation

# Create legend with custom colors and labels
legend_dict = {
    'Forest': '#228B22',
    'Water': '#4169E1', 
    'Urban': '#FF4500',
    'Agriculture': '#FFD700'
}

legend = geemap.Legend(
    title="Land Cover",
    legend_dict=legend_dict,
    position="topright"
)

# Add legend to map
m.add_child(legend)

Colorbar Widget

# Create colorbar for elevation data
vis_params = {'min': 0, 'max': 4000, 'palette': ['blue', 'green', 'red']}

colorbar = geemap.Colorbar(
    vis_params=vis_params,
    label="Elevation (m)",
    orientation="horizontal",
    position="bottomleft"
)

# Add colorbar to map
m.add_child(colorbar)

Interactive Tools

# JavaScript to Python conversion tool
js_converter = geemap.convert_js2py()
js_converter

# Sample collection tool
sample_tool = geemap.collect_samples()
sample_tool

# Open data exploration widget
data_widget = geemap.open_data_widget()
data_widget

Earth Engine Plotting

# Create plotting GUI for Earth Engine data
plot_gui = geemap.ee_plot_gui(m)
plot_gui

# The GUI will provide interactive controls for:
# - Selecting image collections
# - Choosing bands and indices
# - Setting time ranges
# - Defining regions of interest
# - Creating various plot types

Basemap Selector

# Create basemap selector widget
basemap_selector = geemap.BasemapSelector(m)

# This allows interactive switching between:
# - OpenStreetMap variants
# - Google satellite/terrain/roadmap
# - Esri satellite/terrain
# - CartoDB variants
# - And many other basemap providers

Custom Tool Template

# Create custom tool using template
def my_analysis_tool():
    """Custom analysis tool implementation."""
    
    # Tool header
    header = geemap.tool_header_template(
        title="Custom Analysis",
        description="Perform custom geospatial analysis"
    )
    
    # Tool content
    import ipywidgets as widgets
    
    analysis_button = widgets.Button(
        description="Run Analysis",
        button_style="primary"
    )
    
    def on_analysis_click(b):
        print("Running custom analysis...")
    
    analysis_button.on_click(on_analysis_click)
    
    # Combine header and content
    return widgets.VBox([header, analysis_button])

# Use the custom tool
custom_tool = my_analysis_tool()
custom_tool

Types

# Widget configuration
WidgetConfig = Dict[str, Any]

# Tool configuration  
ToolConfig = Dict[str, Union[str, callable, Dict]]

# Legend dictionary format
LegendDict = Dict[str, str]  # {label: color}

# Theme colors
ThemeColors = Dict[str, str]  # {property: color}

# Widget position options
Position = Literal["topleft", "topright", "bottomleft", "bottomright"]

# Colorbar orientation
Orientation = Literal["horizontal", "vertical"]

# Tool collection
ToolCollection = Dict[str, ToolConfig]

Install with Tessl CLI

npx tessl i tessl/pypi-geemap

docs

ai-ml.md

data-conversion.md

data-export.md

earth-engine.md

index.md

interactive-mapping.md

visualization.md

widgets-tools.md

tile.json