Environment and Discovery

This chapter covers environment lifecycle and tool discovery patterns.

Environment setup is where workflow reliability begins. By explicitly creating and configuring a runtime environment, you make script behavior predictable across machines and sessions. Discovery APIs then let you verify capability before execution, which avoids long-running failures caused by missing tools, unexpected categories, or version mismatches.

Create and Configure Environment

This example establishes an explicit runtime configuration. In production scripts, this is where you set working directory and verbosity policy.

import whitebox_workflows as wb

wbe = wb.WbEnvironment()
wbe.working_directory = '/path/to/data'
wbe.verbose = True

print(wbe.version())
print(wbe.license_type())

Namespace Discovery

Use discovery to understand available capability before writing long workflows or generating dynamic tooling UIs.

import whitebox_workflows as wb

wbe = wb.WbEnvironment()

print('categories:', wbe.categories())
print('domains:', wbe.domain_namespaces())
print('terrain tools sample:', wbe.terrain.list_tools()[:15])

Search and Describe Tools

This pattern is useful when you know a task but not the exact tool identifier.

import whitebox_workflows as wb

wbe = wb.WbEnvironment()

matches = wbe.search_tools('slope')
for m in matches[:5]:
	print(m.get('tool_id', m))

desc = wbe.describe_tool('slope')
print(desc)

Discovering Parameter Values with describe_tool

describe_tool returns a dictionary containing structured parameter metadata. Each entry in the params list includes:

KeyAlways presentDescription
nameyesParameter name as used in tool calls
descriptionyesHuman-readable description
requiredyesTrue if the parameter must be supplied
typewhen setSemantic type hint: "string", "float", "int", "bool", "path", "array[int]"
choiceswhen setList of valid string values for constrained parameters
default_valuewhen setDefault value as a string, for display purposes

Use this to enumerate valid values before calling a tool:

import whitebox_workflows as wb

wbe = wb.WbEnvironment()

desc = wbe.describe_tool('lidar_tin_gridding')
for p in desc['params']:
    name = p['name']
    choices = p.get('choices')
    default = p.get('default_value')
    if choices:
        print(f"{name}: choices={choices}, default={default!r}")
    else:
        print(f"{name}: type={p.get('type', 'any')}, default={default!r}")

Example output (selected parameters):

interpolation_parameter: choices=['elevation', 'intensity', 'class', 'return_number', 'number_of_returns', 'scan_angle', 'time', 'rgb', 'user_data'], default='elevation'
returns_included: choices=['all', 'first', 'last'], default='all'
triangulation_backend: choices=['auto', 'delaunator', 'wbtopology'], default='auto'
triangulation_thin_method: choices=['nearest_center', 'min_value', 'max_value'], default='nearest_center'
triangulation_thin_cell_size: type=float, default='0.0'

This is especially useful for building dynamic UIs, generating documentation, or writing validation helpers that do not hard-code allowed values.

Validate Tool Availability

Use hard checks like this in batch scripts so failures occur immediately, before expensive processing begins.

import whitebox_workflows as wb

wbe = wb.WbEnvironment()
available = set(wbe.list_tools())

required = {'fill_depressions', 'd8_flow_accum'}
missing = sorted(required - available)
if missing:
	raise RuntimeError(f'Missing required tools: {missing}')

Category Access Patterns

Prefer direct properties when available:

  • wbe.hydrology
  • wbe.terrain
  • wbe.raster
  • wbe.vector
  • wbe.lidar
  • wbe.remote_sensing
  • wbe.conversion
  • wbe.streams
  • wbe.precision_agriculture
  • wbe.other

Use generic accessors for dynamic workflows:

  • wbe.category(name)
  • wbe.domain(name)

Projection/georeferencing tools are cataloged under the canonical category key projection_georeferencing and can be queried with:

proj_tools = wbe.category('projection_georeferencing').list_tools()
print(proj_tools[:10])

WbEnvironment Method Reference

This reference lists callable WbEnvironment methods with brief descriptions. Special Python dunder methods are intentionally omitted.

Constructors

MethodDescription
from_floating_license_idCreate an environment using a floating license identifier and provider settings.
from_signed_entitlement_fileCreate an environment from a signed entitlement file and public-key metadata.
from_signed_entitlement_jsonCreate an environment from signed entitlement JSON and public-key metadata.

Runtime and Licensing

MethodDescription
versionReturn the Whitebox runtime version string.
license_typeReturn the active license mode (for example open, floating, or entitlement-backed).
license_infoReturn detailed license status information for diagnostics.

Discovery and Introspection

MethodDescription
list_toolsReturn all available tool IDs visible in the current environment.
categoriesReturn the list of top-level tool categories.
categoryReturn a category namespace object by name.
domain_namespacesReturn available domain namespace names.
domainReturn a domain namespace object by name.
describe_toolReturn metadata and parameter details for a specific tool ID.
search_toolsSearch tools by keyword or phrase.
list_tools_detailedReturn expanded metadata for all visible tools.

Core Data Readers

MethodDescription
read_rasterRead one raster into a Raster object.
read_vectorRead one vector dataset into a Vector object.
read_lidarRead one lidar dataset into a Lidar object.
read_rastersRead multiple rasters, optionally in parallel.
read_vectorsRead multiple vectors, optionally in parallel.
read_lidarsRead multiple lidar datasets, optionally in parallel.

Sensor Bundle Readers and Composites

MethodDescription
read_bundleAuto-detect and read a supported sensor bundle.
read_landsatRead a Landsat bundle with family-specific parsing.
read_sentinel2Read a Sentinel-2 SAFE bundle.
read_sentinel1Read a Sentinel-1 SAFE bundle.
read_planetscopeRead a PlanetScope bundle.
read_iceyeRead an ICEYE bundle.
read_dimapRead a DIMAP bundle.
read_maxar_worldviewRead a Maxar/WorldView bundle.
read_radarsat2Read a RADARSAT-2 bundle.
read_rcmRead a RADARSAT Constellation Mission (RCM) bundle.
true_colour_compositeBuild a true-colour composite raster from a bundle source.
false_colour_compositeBuild a false-colour composite raster from a bundle source.

Reprojection Helpers

MethodDescription
reproject_rasterReproject one raster with explicit resampling and grid controls.
reproject_vectorReproject one vector dataset with policy controls.
reproject_lidarReproject one lidar dataset with transform and failure controls.
reproject_rastersBatch reproject multiple rasters.
reproject_vectorsBatch reproject multiple vector datasets.
reproject_lidarsBatch reproject multiple lidar datasets.

Writers and Raster-Memory Management

MethodDescription
write_rasterWrite one raster to disk with optional format options.
write_rastersWrite multiple rasters to disk in one call.
remove_raster_from_memoryDrop a specific memory-backed raster from the environment cache.
clear_raster_memoryClear all memory-backed rasters tracked by the environment.
clear_memoryClear all memory-backed rasters, vectors, and LiDAR objects tracked by the environment.
raster_memory_countReturn the count of memory-backed rasters currently tracked.
raster_memory_bytesReturn the estimated bytes used by tracked memory-backed rasters.
write_vectorWrite one vector dataset to disk with optional format options.
write_lidarWrite one lidar dataset to disk with optional format options.
write_textWrite plain text content to a file path.

Key Environment Properties

PropertyDescription
working_directoryDefault working directory used for relative paths.
verboseControls environment/runtime status output emitted by the bindings.
max_procsMaximum process count used by eligible parallel operations.
projectionNamespace for CRS and coordinate transformation helper methods.
topologyNamespace for geometry-topology helper methods.
hydrology, terrain, raster, vector, lidar, remote_sensingPrimary category namespaces for tool discovery and execution.
precision_agriculturePro-tier precision agriculture tools (yield zoning, irrigation, crop stress, trafficability).
conversion, streams, otherAdditional category namespaces available in the environment.