or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

ai-ml.mddata-conversion.mddata-export.mdearth-engine.mdindex.mdinteractive-mapping.mdvisualization.mdwidgets-tools.md

widgets-tools.mddocs/

0

# Interactive Widgets and Tools

1

2

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

3

4

## Capabilities

5

6

### Layer Management Widgets

7

8

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

9

10

```python { .api }

11

class LayerManager:

12

"""Interactive layer management widget."""

13

14

def __init__(self, map_object) -> None:

15

"""

16

Initialize layer manager.

17

18

Args:

19

map_object: Map instance to manage layers for

20

"""

21

22

class LayerManagerRow:

23

"""Individual row in layer manager representing one layer."""

24

25

def __init__(self, layer, **kwargs) -> None:

26

"""

27

Initialize layer manager row.

28

29

Args:

30

layer: Map layer object

31

**kwargs: Additional parameters

32

"""

33

34

class LayerEditor:

35

"""Widget for editing layer properties and visualization parameters."""

36

37

def __init__(self, map_object, layer=None, **kwargs) -> None:

38

"""

39

Initialize layer editor.

40

41

Args:

42

map_object: Map instance

43

layer: Layer to edit (optional)

44

**kwargs: Additional parameters

45

"""

46

```

47

48

### Data Inspector

49

50

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

51

52

```python { .api }

53

class Inspector:

54

"""Interactive map data inspector widget."""

55

56

def __init__(self, map_object, **kwargs) -> None:

57

"""

58

Initialize data inspector.

59

60

Args:

61

map_object: Map instance to attach inspector to

62

**kwargs: Additional parameters

63

"""

64

65

def inspector_gui(m=None, **kwargs) -> widgets.VBox:

66

"""

67

Create inspector GUI widget.

68

69

Args:

70

m: Map object to inspect

71

**kwargs: Additional parameters

72

73

Returns:

74

Inspector widget container

75

"""

76

```

77

78

### Basemap Selector

79

80

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

81

82

```python { .api }

83

class BasemapSelector:

84

"""Interactive basemap selection widget."""

85

86

def __init__(self, map_object, **kwargs) -> None:

87

"""

88

Initialize basemap selector.

89

90

Args:

91

map_object: Map instance

92

**kwargs: Additional parameters

93

"""

94

```

95

96

### Toolbar System

97

98

Comprehensive toolbar system with customizable tools and interactive widgets.

99

100

```python { .api }

101

class Toolbar:

102

"""Main toolbar widget with multiple tools."""

103

104

def __init__(self, map_object, **kwargs) -> None:

105

"""

106

Initialize toolbar.

107

108

Args:

109

map_object: Map instance to attach toolbar to

110

**kwargs: Additional parameters

111

"""

112

113

class ToolbarItem:

114

"""Individual toolbar item widget."""

115

116

def __init__(

117

self,

118

widget,

119

icon: str = "wrench",

120

tooltip: str = "",

121

**kwargs

122

) -> None:

123

"""

124

Initialize toolbar item.

125

126

Args:

127

widget: Widget to include in toolbar

128

icon: Font Awesome icon name

129

tooltip: Tooltip text

130

**kwargs: Additional parameters

131

"""

132

133

def get_tools_dict() -> Dict[str, Dict]:

134

"""

135

Get dictionary of available toolbar tools.

136

137

Returns:

138

Dictionary mapping tool names to tool configurations

139

"""

140

```

141

142

### Plotting and Analysis Tools

143

144

Interactive tools for Earth Engine data plotting and analysis.

145

146

```python { .api }

147

def ee_plot_gui(m=None, **kwargs) -> widgets.VBox:

148

"""

149

Create Earth Engine plotting GUI.

150

151

Args:

152

m: Map object for plotting

153

**kwargs: Additional parameters

154

155

Returns:

156

Plotting widget container

157

"""

158

159

def tool_template(**kwargs) -> widgets.VBox:

160

"""

161

Generic tool template for creating custom tools.

162

163

Args:

164

**kwargs: Tool configuration parameters

165

166

Returns:

167

Tool widget container

168

"""

169

170

def tool_header_template(

171

title: str = "Tool",

172

description: str = "",

173

**kwargs

174

) -> widgets.VBox:

175

"""

176

Create tool header template.

177

178

Args:

179

title: Tool title

180

description: Tool description

181

**kwargs: Additional parameters

182

183

Returns:

184

Header widget

185

"""

186

```

187

188

### Data Collection and Conversion Tools

189

190

Interactive tools for collecting samples and converting between data formats.

191

192

```python { .api }

193

def collect_samples(**kwargs) -> widgets.VBox:

194

"""

195

Create sample collection tool.

196

197

Args:

198

**kwargs: Tool parameters

199

200

Returns:

201

Sample collection widget

202

"""

203

204

def convert_js2py(**kwargs) -> widgets.VBox:

205

"""

206

Create JavaScript to Python conversion tool.

207

208

Args:

209

**kwargs: Conversion parameters

210

211

Returns:

212

Conversion tool widget

213

"""

214

215

def open_data_widget(**kwargs) -> widgets.VBox:

216

"""

217

Create open data exploration widget.

218

219

Args:

220

**kwargs: Widget parameters

221

222

Returns:

223

Data exploration widget

224

"""

225

```

226

227

### Legend and Colorbar Widgets

228

229

Interactive widgets for displaying and managing map legends and colorbars.

230

231

```python { .api }

232

class Legend:

233

"""Interactive legend widget for maps."""

234

235

def __init__(

236

self,

237

title: str = "Legend",

238

legend_dict: Dict = None,

239

keys: List[str] = None,

240

colors: List[str] = None,

241

position: str = "bottomright",

242

**kwargs

243

) -> None:

244

"""

245

Initialize legend widget.

246

247

Args:

248

title: Legend title

249

legend_dict: Legend configuration dictionary

250

keys: Legend item labels

251

colors: Legend item colors

252

position: Legend position on map

253

**kwargs: Additional parameters

254

"""

255

256

class Colorbar:

257

"""Interactive colorbar widget."""

258

259

def __init__(

260

self,

261

vis_params: Dict = None,

262

cmap: str = "gray",

263

discrete: bool = False,

264

label: str = None,

265

orientation: str = "horizontal",

266

position: str = "bottomright",

267

**kwargs

268

) -> None:

269

"""

270

Initialize colorbar widget.

271

272

Args:

273

vis_params: Visualization parameters

274

cmap: Colormap name

275

discrete: Use discrete colors

276

label: Colorbar label

277

orientation: Colorbar orientation

278

position: Colorbar position on map

279

**kwargs: Additional parameters

280

"""

281

```

282

283

### Theme and Styling

284

285

Widget theming and styling utilities for consistent appearance.

286

287

```python { .api }

288

class Theme:

289

"""Widget theme configuration."""

290

291

def __init__(

292

self,

293

primary_color: str = "#3388ff",

294

secondary_color: str = "#ffffff",

295

**kwargs

296

) -> None:

297

"""

298

Initialize theme.

299

300

Args:

301

primary_color: Primary theme color

302

secondary_color: Secondary theme color

303

**kwargs: Additional theme parameters

304

"""

305

306

class TypedTuple:

307

"""Typed tuple container for widget data."""

308

309

def __init__(self, items: List = None, **kwargs) -> None:

310

"""

311

Initialize typed tuple.

312

313

Args:

314

items: List of items

315

**kwargs: Additional parameters

316

"""

317

```

318

319

### Advanced Widget Utilities

320

321

Utilities for widget management and CSS styling in notebook environments.

322

323

```python { .api }

324

def _set_css_in_cell_output(css_text: str) -> None:

325

"""

326

Set CSS styling in notebook cell output.

327

328

Args:

329

css_text: CSS styling text

330

"""

331

```

332

333

## Usage Examples

334

335

### Layer Management

336

337

```python

338

import geemap

339

340

# Create map

341

m = geemap.Map()

342

343

# Add some layers

344

m.add_basemap('OpenStreetMap')

345

m.addLayer(ee.Image('USGS/SRTMGL1_003'), {'min': 0, 'max': 4000}, 'Elevation')

346

347

# Create layer manager

348

layer_manager = geemap.LayerManager(m)

349

350

# Display layer manager

351

layer_manager

352

```

353

354

### Data Inspector

355

356

```python

357

# Create inspector for interactive data exploration

358

inspector = geemap.Inspector(m)

359

360

# Or use the GUI version

361

inspector_gui = geemap.inspector_gui(m)

362

inspector_gui

363

```

364

365

### Custom Toolbar

366

367

```python

368

# Create custom toolbar

369

toolbar = geemap.Toolbar(m)

370

371

# Add custom tool

372

def custom_tool_function():

373

print("Custom tool activated!")

374

375

custom_item = geemap.ToolbarItem(

376

widget=custom_tool_function,

377

icon="cog",

378

tooltip="Custom Tool"

379

)

380

381

# Get available tools

382

tools = geemap.get_tools_dict()

383

print("Available tools:", list(tools.keys()))

384

```

385

386

### Legend Creation

387

388

```python

389

# Create legend with custom colors and labels

390

legend_dict = {

391

'Forest': '#228B22',

392

'Water': '#4169E1',

393

'Urban': '#FF4500',

394

'Agriculture': '#FFD700'

395

}

396

397

legend = geemap.Legend(

398

title="Land Cover",

399

legend_dict=legend_dict,

400

position="topright"

401

)

402

403

# Add legend to map

404

m.add_child(legend)

405

```

406

407

### Colorbar Widget

408

409

```python

410

# Create colorbar for elevation data

411

vis_params = {'min': 0, 'max': 4000, 'palette': ['blue', 'green', 'red']}

412

413

colorbar = geemap.Colorbar(

414

vis_params=vis_params,

415

label="Elevation (m)",

416

orientation="horizontal",

417

position="bottomleft"

418

)

419

420

# Add colorbar to map

421

m.add_child(colorbar)

422

```

423

424

### Interactive Tools

425

426

```python

427

# JavaScript to Python conversion tool

428

js_converter = geemap.convert_js2py()

429

js_converter

430

431

# Sample collection tool

432

sample_tool = geemap.collect_samples()

433

sample_tool

434

435

# Open data exploration widget

436

data_widget = geemap.open_data_widget()

437

data_widget

438

```

439

440

### Earth Engine Plotting

441

442

```python

443

# Create plotting GUI for Earth Engine data

444

plot_gui = geemap.ee_plot_gui(m)

445

plot_gui

446

447

# The GUI will provide interactive controls for:

448

# - Selecting image collections

449

# - Choosing bands and indices

450

# - Setting time ranges

451

# - Defining regions of interest

452

# - Creating various plot types

453

```

454

455

### Basemap Selector

456

457

```python

458

# Create basemap selector widget

459

basemap_selector = geemap.BasemapSelector(m)

460

461

# This allows interactive switching between:

462

# - OpenStreetMap variants

463

# - Google satellite/terrain/roadmap

464

# - Esri satellite/terrain

465

# - CartoDB variants

466

# - And many other basemap providers

467

```

468

469

### Custom Tool Template

470

471

```python

472

# Create custom tool using template

473

def my_analysis_tool():

474

"""Custom analysis tool implementation."""

475

476

# Tool header

477

header = geemap.tool_header_template(

478

title="Custom Analysis",

479

description="Perform custom geospatial analysis"

480

)

481

482

# Tool content

483

import ipywidgets as widgets

484

485

analysis_button = widgets.Button(

486

description="Run Analysis",

487

button_style="primary"

488

)

489

490

def on_analysis_click(b):

491

print("Running custom analysis...")

492

493

analysis_button.on_click(on_analysis_click)

494

495

# Combine header and content

496

return widgets.VBox([header, analysis_button])

497

498

# Use the custom tool

499

custom_tool = my_analysis_tool()

500

custom_tool

501

```

502

503

## Types

504

505

```python { .api }

506

# Widget configuration

507

WidgetConfig = Dict[str, Any]

508

509

# Tool configuration

510

ToolConfig = Dict[str, Union[str, callable, Dict]]

511

512

# Legend dictionary format

513

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

514

515

# Theme colors

516

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

517

518

# Widget position options

519

Position = Literal["topleft", "topright", "bottomleft", "bottomright"]

520

521

# Colorbar orientation

522

Orientation = Literal["horizontal", "vertical"]

523

524

# Tool collection

525

ToolCollection = Dict[str, ToolConfig]

526

```