FFT Convolution Documentation

Introduction

FFT Convolution plugin's core was build with the Plugin builder; most of the files and functions come from it. This documentation is focused on the others, specific for this plugin.

File architecture

The following files in the plugin repository were autogenerated by Plugin Builder and weren't changed:

__init__.py
fft_filter_dialog.py
Makefile
resources.qrc
resources.py

Other pregenerated files were changed:

fft_filter_dialog_base.ui

fft_filter_dialog_base.py
fft_filter.py
icon.png
metadata.txt
README.html
README.txt

Other files are new:

LICENSE.txt - GPL 3.0
docs/ - subdirectory for documentation
docs/version0.1.1.txt - what's new in current version
docs/documentation.html
docs/documentation.txt
examples/ - example data
examples/metadata.txt - documentation of examples
examples/smallaster.img - raster example taken from Chris Garrard's Python for Geoprocessing course materials

FFTConvolution class overview - file fft_filter.py

Some methods were autogenerated by Plugin Builder - they don't need special documentation here:

__init__
tr
add_action
initGui
unload
select_output_file

Other methods are new:

fft_convolution

This method parses the arguments and passes them to the gaussian_filter method.

parameters:

in_layer - input layer as an object of class QgsRasterLayer.
out_path - path to the output layer.
size (optional) - size of the filtering buffer in pixels. Default is 10.
edge (optional) - either False for smoothing or True for edge detection. Default is False.
new_crs (optional) - coordinate system as an object of class QgsCoordinateReferenceSystem. Default is None.
tiled (optional) - True means the windowed algorithm will be used. Default is False.
tilerows (optional) - size of the tile's x-axis. Default 0 means that either tilecols, raster's native blocks or windows computed from the filter size will be used (in this order).
tilecols (optional) - size of the tile's y-axis. Default 0 means that either tilerows, raster's native blocks or windows computed from the filter size will be used (in this order).
add_layer (optional) - True means the output layer will be added to the map. Default is True.

Return value: void

gaussian_filter

Filters a raster specified by the file's path and writes it to another file.

parameters:

in_path - path to the output layer.
out_path - path to the output layer.
size (optional) - size of the filtering buffer in pixels. Default is 10.
edge (optional) - either False for smoothing or True for edge detection. Default is False.
new_crs (optional) - coordinate system as an object of class QgsCoordinateReferenceSystem. Default is None.
tiled (optional) - True means the windowed algorithm will be used. Default is False.
tilerows (optional) - size of the tile's x-axis. Default 0 means that either tilecols, raster's native blocks or windows computed from the filter size will be used (in this order).
tilecols (optional) - size of the tile's y-axis. Default 0 means that either tilerows, raster's native blocks or windows computed from the filter size will be used (in this order).
add_layer (optional) - True means the output layer will be added to the map. Default is True.

Return value: output layer - QgsRasterLayer

__array_rank

Returns number of array dimensionsreturns number of array dimensions.

__load_layer

Loads the newly created layer after running gaussian_filter.

__extend_window

Pads the window to process its original extend accurately.

__generate_windows

Creates a window generator, in the same format as it is returned by block_windows rasterio method.

__generate_window_array

Like __generate_windows(), but returns an array.

__compute_windows

Processes the window parameters.

Return value: either generator or array of windows

__compute_transform

Computes the affine transformation, raster dimensions and metadata for the new raster.

__reproject

Calls reproject() function for every band.

__gaussian_blur1d

The original MikeT's function from http://gis.stackexchange.com/a/10467. My addition is the conversion of the padded array to float to avoid errors with integer rasters. The intended input is a single band raster array.

__gaussian_blur

The intended input is an array with various number of bands.