convolve#
Signature#
- convolve(field, kernel) Field#
Sum all values in a neighbourhood, multiplied by their weights
- Parameters:
field (Field) – Field to analyse (array / floating point)
kernel (Kernel) – Neighbourhood to search. The weights must be floating point and will be used to multiply each cell’s value with.
- Returns:
New field (array / floating point)
Description#
Focal operation summing all values in a neighbourhood, multiplied by their weights.
Formula for computing a result for a single cell \((row, col)\), given an array \(A\) and a 3x3 kernel \(K\):
No-data handling#
As long as there is at least one valid value found within the input neighbourhood, a valid value is written to the focal cell in the output field. Only when no such value is found is a no-data value written. The output field is likely to contain less no-data values than the input field.
Example#
LUE_Field* array = lue_from_gdal(argument_array_pathname);
LUE_Kernel* kernel = lue_read_kernel(argument_kernel_pathname);
LUE_Field* result = lue_convolve(array, kernel);
lue_to_gdal(result, result_array_pathname, NULL);
lue_destruct(array);
lue_destruct(kernel);
lue_destruct(result);
Field const array = from_gdal(argument_array_pathname);
Kernel const kernel = lue::document::read_kernel(argument_kernel_pathname);
Field const result = convolve(array, kernel);
to_gdal(result, result_array_pathname);
array = lfrx.from_gdal(str(argument_array_path))
kernel = ld.read_kernel(argument_kernel_path)
result = lfrx.convolve(array, kernel)
lfrx.to_gdal(result, str(result_array_path))
|
|
|
|---|---|---|
See also#
See
focal_sum()for an operation which sums values without multiplying them by weights