r.resamp.filter(1grass)
π r.resamp.filter β the GRASS User's Manual page, bestie edition π
okay so. this is r.resamp.filter from the GRASS manual (yes, the (1grass) one, section 1, GRASS fam π«Ά). it resamples raster map layers using an analytic kernel. and honestly? it's giving math girlboss. let's get into it. β¨
β¨ NAME β¨
r.resamp.filter β resamples raster map layers using an analytic kernel. no cap, that's literally the whole name. π
π·οΈ KEYWORDS π·οΈ
raster, resample, kernel filter, filter, convolution, FIR, bartlett, blackman, box, gauss, hamming, hann, hermite, lanczos, sinc, parallel
(iykyk β these are the vibes the module is tagged with.)
π¦ SYNOPSIS π¦
r.resamp.filter
r.resamp.filter --help
r.resamp.filter [-n] input=name output=name filter=string[,string,...]
[radius=float[,float,...]] [x_radius=float[,float,...]]
[y_radius=float[,float,...]] [memory=memory in MB] [nprocs=integer]
[--overwrite] [--help] [--verbose] [--quiet] [--ui]
π© Flags π©
-nβ Propagate NULLs. yes queen, send those NULLs through, don't ghost them π--overwriteβ Allow output files to overwrite existing files. let it slay over the old one π--helpβ Print usage summary. when u need the tea β--verboseβ Verbose module output. talkative era π£οΈ--quietβ Quiet module output. silent era π€«--uiβ Force launching GUI dialog. for when clicking > typing β¨
π Parameters π
input=name[required] β Name of input raster map. ur source material bestie πΊοΈoutput=name[required] β Name for output raster map. the glow-up result πfilter=string[,string,...][required] β Filter kernel(s). Options:box,bartlett,gauss,normal,hermite,sinc,lanczos1,lanczos2,lanczos3,hann,hamming,blackmanradius=float[,float,...]β Filter radius. in map units, periodt πx_radius=float[,float,...]β Filter radius (horizontal). left-right vibes βοΈy_radius=float[,float,...]β Filter radius (vertical). up-down vibes βοΈmemory=memory in MBβ Maximum memory to be used (in MB). Cache size for raster rows. Default:300. don't eat all the RAM bb πnprocs=integerβ Number of threads for parallel computing.0: use OpenMP default; >0: usenprocs; <0: useMAX-nprocsDefault:0. main character energy, make it go fast π₯
πΈ DESCRIPTION πΈ
r.resamp.filter resamples an input raster, filtering the input with an analytic kernel. Here's the tea: each output cell is typically calculated based upon a small subset of the input cells β not the entire input. like, it's not reading the whole group chat, just the last few messages π. and r.resamp.filter performs convolution (i.e. a weighted sum is calculated for every raster cell). weighted sum go brrr.
The radii must be given in map units. lowkey important: in order to consider more than one input cell, at least one finite radius must be larger than half the resolution of the input map, otherwise the selected kernels will have no effect. so like, if ur radius is too tiny, the kernels do absolutely nothing and that's just embarrassing for everyone π«
The module maps the input range to the width of the window function, so wider windows will be "sharper" (have a higher cut-off frequency), e.g. lanczos3 will be sharper than lanczos2. it's giving glow-up, fr fr.
r.resamp.filter implements FIR (finite impulse response) filtering. All of the functions are low-pass filters, as they are symmetric. See Wikipedia: Window function for examples of common window functions and their frequency responses. (yes we're citing Wikipedia, she's iconic, deal with it π)
A piecewise-continuous function defined by sampled data can be considered a mixture (sum) of the underlying signal and quantisation noise. The intent of a low pass filter is to discard the quantisation noise while retaining the signal. like keeping the bestie and blocking the noise, we love a boundaries era π«. The cut-off frequency is normally chosen according to the sampling frequency, as the quantisation noise is dominated by the sampling frequency and its harmonics. In general, the cut-off frequency is inversely proportional to the width of the central "lobe" of the window function.
When using r.resamp.filter with a specific radius, a specific cut-off frequency regardless of the method is chosen. So while lanczos3 uses 3 times as large a window as lanczos1, the cut-off frequency remains the same. Effectively, the radius is "normalised". normalized queen π
All of the kernels specified by the filter parameter are multiplied together. Typical usage will use either a single finitie window or an infinite kernel along with a finite window.
π§ Usage hints π§
(these are literally cheat codes, screenshot them)
- To smooth a map, keeping its resolution, a good starting point is to use the filters
gauss,boxwith the radii0.5 * input resolution,2 * input resolution. See alsor.neighbors. soft-launch smooth β¨ - When resampling a map to a higher resolution (alternative to interpolation, e.g.
r.resamp.interp), a good starting point is to use the filtersgauss,boxwith the radii1.5 * input resolution,3 * input resolution. zoom in era π - When resampling a map to a lower resolution (alternative to aggregation, e.g.
r.resamp.stats), a good starting point is to use the filtersgauss,boxwith the radii0.25 * output resolution,1 * output resolution. zoom out era π
These are recommendations for initial settings. The selection of filters and radii might need adjustment according to the actual purpose. so like, these are starter fits, tailor them to ur body of work okurrr π
π NOTES π
Resampling modules (r.resample, r.resamp.stats, r.resamp.interp, r.resamp.rst, r.resamp.filter) resample the map to match the current region settings. so check ur g.region first bestie, they all follow the region's rules.
β οΈ When using a kernel which can have negative values (sinc, Lanczos), the-nflag should be used. Otherwise, extreme values can arise due to the total weight being close (or even equal) to zero. so like... use-nor get jumpscared by numbers. literally. π
Kernels with infinite extent (Gauss, normal, sinc, Hann, Hamming, Blackman) must be used in conjunction with a finite windowing function (box, Bartlett, Hermite, Lanczos). infinite kernel can't be out here alone, she needs a finite window chaperone π«Ά
The way that Lanczos filters are defined, the number of samples is supposed to be proportional to the order ("a" parameter), so lanczos3 should use 3 times as many samples (at the same sampling frequency, i.e. cover 3 times as large a time interval) as lanczos1 in order to get a similar frequency response (higher-order filters will fall off faster, but the frequency at which the fall-off starts should be the same). See Wikipedia: Lanczos-kernel.svg for an illustration. If both graphs were drawn on the same axes, they would have roughly the same shape, but the a=3 window would have a longer tail. By scaling the axes to the same width, the a=3 window has a narrower central lobe. the way that lanczos3 has a whole longer tail and a narrower central lobe... obsessed π¦
For longitude-latitude coordinate reference systems, the interpolation algorithm is based on degree fractions, not on the absolute distances between cell centers. Any attempt to implement the latter would violate the integrity of the interpolation method. so like, don't come in here trying to do absolute distances, it's not that kind of party π ββοΈ
π₯ PERFORMANCE π₯
By specifying the number of parallel processes with nprocs option, r.resamp.filter can run faster, see benchmarks below.
Figure: Benchmark shows execution time for different number of cells. See benchmark script in the source code. (go look, the graph is giving data diva π)
To reduce the memory requirements to minimum, set option memory to zero. To take advantage of the parallelization, GRASS needs to compiled with OpenMP enabled. (yes β "needs to compiled", we're keeping it exactly as written, character for character, no fixing, that's the rule π
)
π SEE ALSO π
g.region, r.mfilter, r.resample, r.resamp.interp, r.resamp.rst, r.resamp.stats
Overview: Interpolation and Resampling in GRASS
π AUTHOR π
Glynn Clements
β SOURCE CODE β
Available at: r.resamp.filter source code (history)
Latest change: Friday Aug 08 09:39:19 2025 in commit: ed72c71d8580e872cd6fd345c84a15c324764465
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
okay that's the whole page bestie, u made it to the end and i'm so proud π₯Ήπ one final cute sign-off: this was GRASS 8.5.0, straight out of the GRASS 8.5.0 Reference Manual, Β© 2003-2026 GRASS Development Team β love that for them, love that for us π«Άβ¨ go forth and resample, periodt π πΈ
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms