Authoring a Lambda
Spatial lambdas are typically composed of three main components:
1. Input Definition
Specify the dataset(s) and region of interest (bounding box or selection) to process.
2. Compute Function
Write code that iterates through voxels and applies your logic. For example, summing the ore_grade property forvoxels above a grade threshold.
3. Output
Return a summary value (e.g., total_volume) or create a new dataset (e.g., filtered voxels). Lambdas can alsoattach files or emit logs during execution.
Sample Python Lambda
Here's a basic example that sums the volume of high-grade voxels:
def lambda_handler (context, voxel_reader, voxel_writer):
total_volume = 0.0
for voxel in voxel_reader:
if voxel.properties.get('grade',0.0) >= 0.5:
total_volume += voxel.size
return {'total_volume': total_volume}
Code Explanation
voxel_reader: Provides voxel objects with property dictionaries and geometry
voxel.properties.get('grade', 0.0): Safely retrieves the grade property with a default valueof 0.0
voxel.size: Represents the volume of a voxel (e.g., 1 m³)
Return value: Dictionary with the computed total volume that will appear in reports