lib.filtlib module¶
Library of spatial filters for 2D NumPy arrays
-
pygeotools.lib.filtlib.butter(dt_list, val, lowpass=1.0)[source]¶ This is framework for a butterworth bandpass for 1D data
Needs to be cleaned up and generalized
-
pygeotools.lib.filtlib.circular_mask(size)[source]¶ Create a circular mask for an array
Useful when sampling rasters for a laser shot
-
pygeotools.lib.filtlib.dz_fltr(dem_fn, refdem_fn, perc=None, rangelim=(0, 30), smooth=False)[source]¶ Absolute elevation difference range filter using values from a source raster file and a reference raster file
-
pygeotools.lib.filtlib.dz_fltr_ma(dem, refdem, perc=None, rangelim=(0, 30), smooth=False)[source]¶ Absolute elevation difference range filter using values from a source array and a reference array
-
pygeotools.lib.filtlib.freq_filt(bma)[source]¶ This is a framework for 2D FFT filtering. It has not be tested or finished - might be a dead end
See separate utility freq_analysis.py
-
pygeotools.lib.filtlib.gauss_fltr_astropy(dem, size=None, sigma=None, origmask=False, fill_interior=False)[source]¶ Astropy gaussian filter properly handles convolution with NaN
width1 = 3; sigma1 = (width1-1) / 6; Specify width for smallest feature of interest and determine sigma appropriately
sigma is width of 1 std in pixels (not multiplier)
scipy and astropy both use cutoff of 4*sigma on either side of kernel - 99.994%
3*sigma on either side of kernel - 99.7%
If sigma is specified, filter width will be a multiple of 8 times sigma
Alternatively, specify filter size, then compute sigma: sigma = (size - 1) / 8.
If size is < the required width for 6-8 sigma, need to use different mode to create kernel
mode ‘oversample’ and ‘center’ are essentially identical for sigma 1, but very different for sigma 0.3
The sigma/size calculations below should work for non-integer sigma
-
pygeotools.lib.filtlib.gauss_fltr_opencv(dem, size=3, sigma=1)[source]¶ OpenCV Gaussian filter Still propagates NaN values
-
pygeotools.lib.filtlib.gauss_fltr_pyramid(dem, size=None, full=False, origmask=False)[source]¶ Pyaramidal downsampling approach for gaussian smoothing Avoids the need for large kernels, very fast Needs testing
-
pygeotools.lib.filtlib.mad_fltr(dem, n=3)[source]¶ Median absolute deviation * factor filter
Robust outlier removal
-
pygeotools.lib.filtlib.median_fltr(dem, fsize=7, origmask=False)[source]¶ Scipy.ndimage median filter
Does not properly handle NaN
-
pygeotools.lib.filtlib.median_fltr_skimage(dem, radius=3, erode=1, origmask=False)[source]¶ Older skimage.filter.median_filter
This smooths, removes noise and fills in nodata areas with median of valid pixels! Effectively an inpainting routine
-
pygeotools.lib.filtlib.rolling_fltr(dem, f=<Mock id='140637716130256'>, size=3, circular=True, origmask=False)[source]¶ General rolling filter (default operator is median filter)
Can input any function f
Efficient for smaller arrays, correclty handles NaN, fills gaps