t.rast.neighbors(1grass)

✨ t.rast.neighbors ✨

okay bestie, gather round, because t.rast.neighbors is literally the glow-up module for your space time raster dataset πŸ’– it does a neighborhood analysis on every single map in a STRDS, one by one, no map left behind. periodt.

KEYWORDS: temporal, aggregation, raster, time πŸ¦‹


🌸 SYNOPSIS 🌸

t.rast.neighbors
t.rast.neighbors --help
t.rast.neighbors [-cenr] input=name output=name  [where=sql_query]
[region_relation=string]   [selection=name]   [size=integer]
method=string  [weighting_function=string]   [weighting_factor=float]
[weight=name]   [quantile=float[,float,...]]  basename=string
[suffix=name]   [semantic_labels=string]   [nprocs=integer]
[--overwrite]  [--help]  [--verbose]  [--quiet]  [--ui]

πŸŽ€ Flags

  • -c β€” Use circular neighborhood πŸ”΅
  • -e β€” Extend existing space time raster dataset
  • -n β€” Register Null maps
  • -r β€” Ignore the current region settings and use the raster map regions
  • --overwrite β€” Allow output files to overwrite existing files
  • --help β€” Print usage summary
  • --verbose β€” Verbose module output
  • --quiet β€” Quiet module output
  • --ui β€” Force launching GUI dialog

🧚 Parameters

  • input=name [required] β€” Name of the input space time raster dataset
  • output=name [required] β€” Name of the output space time raster dataset
  • where=sql_query β€” WHERE conditions of SQL statement without 'where' keyword used in the temporal GIS framework Example: start_time > '2001-01-01 12:30:00'
  • region_relation=string β€” Process only maps with this spatial relation to the current computational region Options: overlaps, contains, is_contained
  • selection=name β€” Name of an input raster map to select the cells which should be processed
  • size=integer β€” Neighborhood size Default: 3
  • method=string [required] β€” Aggregate operation to be performed on the raster maps Options: average, median, mode, minimum, maximum, range, stddev, sum, count, variance, diversity, interspersion, quart1, quart3, perc90, quantile Default: average
  • weighting_function=string β€” Weighting function Options: none, gaussian, exponential, file Default: none
    • none: No weighting
    • gaussian: Gaussian weighting function
    • exponential: Exponential weighting function
    • file: File with a custom weighting matrix
  • weighting_factor=float β€” Factor used in the selected weighting function (ignored for weighting_function=none and file)
  • weight=name β€” Text file containing weights
  • quantile=float[,float,...] β€” Quantile to calculate for method=quantile Options: 0.0-1.0
  • basename=string [required] β€” Basename of the new generated output maps A numerical suffix separated by an underscore will be attached to create a unique identifier
  • suffix=name β€” Suffix to add at basename: set 'gran' for granularity, 'time' for the full time format, 'num' for numerical suffix with a specific number of digits (default %%05) Default: gran
  • semantic_labels=string β€” Set semantic labels Options: input, method Default: input
    • input: copy semantic labels from input to output
    • method: append method name to input label if existing, otherwise use method name
  • nprocs=integer β€” Number of r.neighbor processes to run in parallel Default: 1

πŸ’… DESCRIPTION πŸ’…

so t.rast.neighbors performs r.neighbors computations on the maps of a space time raster dataset (STRDS). it supports all the options that are available in r.neighbors, so you already know the vibe 😌

you must provide an input and an output space time raster dataset, plus the basename of the resulting raster maps. the resulting STRDS will have the same temporal resolution as the input dataset. with the -e flag, resulting maps can be registered in an existing STRDS β€” one that, say, may have been created with a previous run of t.rast.neighbors. cute, right? 🫢

all maps will be processed using the current region settings unless the -r flag is selected. in that latter case, the computaional region is set to each raster map selected from the input STRDS.

you can select a subset of the input space time raster dataset for processing using a SQL WHERE statement, or using region_relation for spatial selection of raster maps πŸ”. for the spatial map selection, the current computational region is used, even when the -r flag is given. and the number of CPU's to be used for parallel processing can be specified with the nprocs option, to speedup the computation on multi-core system πŸƒβ™€οΈπŸ’¨

semantic labels are needed to relate output raster maps to input raster maps. e.g. with method=stddev, you need to know the spatial extent, the time stamp and the semantic label to determine which stddev map corresponds to which input map. it's giving detective work πŸ”Ž


🌈 EXAMPLE 🌈

to smooth the maps contained in a space time dataset run:

t.rast.neighbors input=tempmean_monthly output=smooth_tempmean_monthly \
                 basename=tmean_smooth size=5 method=average nprocs=4
# show some info about the new space time dataset
t.info smooth_tempmean_monthly
 +-------------------- Space Time Raster Dataset -----------------------------+
 |                                                                            |
 +-------------------- Basic information -------------------------------------+
 | Id: ........................ smooth_tempmean_monthly@climate_2000_2012
 | Name: ...................... smooth_tempmean_monthly
 | Mapset: .................... climate_2000_2012
 | Creator: ................... lucadelu
 | Temporal type: ............. absolute
 | Creation time: ............. 2014-11-27 11:41:36.444579
 | Modification time:.......... 2014-11-27 11:41:39.978232
 | Semantic type:.............. mean
 +-------------------- Absolute time -----------------------------------------+
 | Start time:................. 2009-01-01 00:00:00
 | End time:................... 2013-01-01 00:00:00
 | Granularity:................ 1 month
 | Temporal type of maps:...... interval
 +-------------------- Spatial extent ----------------------------------------+
 | North:...................... 320000.0
 | South:...................... 10000.0
 | East:.. .................... 935000.0
 | West:....................... 120000.0
 | Top:........................ 0.0
 | Bottom:..................... 0.0
 +-------------------- Metadata information ----------------------------------+
 | Raster register table:...... raster_map_register_ea1c9a83524e41a784d72744b08c6107
 | North-South resolution min:. 500.0
 | North-South resolution max:. 500.0
 | East-west resolution min:... 500.0
 | East-west resolution max:... 500.0
 | Minimum value min:.......... -6.428905
 | Minimum value max:.......... 18.867296
 | Maximum value min:.......... 4.247691
 | Maximum value max:.......... 28.767953
 | Aggregation type:........... None
 | Number of registered maps:.. 48
 |
 | Title:
 | Monthly precipitation
 | Description:
 | Dataset with monthly precipitation
 | Command history:
 | # 2014-11-27 11:41:36
 | t.rast.neighbors input="tempmean_monthly"
 |     output="smooth_tempmean_monthly" basename="tmean_smooth" size="5"
 |     method="average" nprocs="4"
 |
 +----------------------------------------------------------------------------+
# now compare the values between the original and the smoothed dataset
t.rast.list input=smooth_tempmean_monthly columns=name,start_time,min,max
name|start_time|min|max
tmean_smooth_1|2009-01-01 00:00:00|-3.361714|7.409861
tmean_smooth_2|2009-02-01 00:00:00|-1.820261|7.986794
tmean_smooth_3|2009-03-01 00:00:00|2.912971|11.799684
...
tmean_smooth_46|2012-10-01 00:00:00|9.38767|18.709297
tmean_smooth_47|2012-11-01 00:00:00|1.785653|10.911189
tmean_smooth_48|2012-12-01 00:00:00|1.784212|11.983857
t.rast.list input=tempmean_monthly columns=name,start_time,min,max
name|start_time|min|max
2009_01_tempmean|2009-01-01 00:00:00|-3.380823|7.426054
2009_02_tempmean|2009-02-01 00:00:00|-1.820261|8.006386
2009_03_tempmean|2009-03-01 00:00:00|2.656992|11.819274
...
2012_10_tempmean|2012-10-01 00:00:00|9.070884|18.709297
2012_11_tempmean|2012-11-01 00:00:00|1.785653|10.911189
2012_12_tempmean|2012-12-01 00:00:00|1.761019|11.983857

look at those before/after numbers, the smoothed dataset really ate πŸ”₯


πŸ¦‹ SEE ALSO πŸ¦‹

  • r.neighbors
  • t.rast.aggregate.ds
  • t.rast.extract
  • t.info
  • g.region
  • r.mask

πŸ‘‘ AUTHOR πŸ‘‘

SΓΆren Gebbert, ThΓΌnen Institute of Climate-Smart Agriculture


πŸ’œ SOURCE CODE πŸ’œ

Available at: t.rast.neighbors source code (history)

Latest change: Tuesday Jan 27 12:40:13 2026 in commit: 5e8b13d47dd4fc81efa5abefe90c34f7a8291fb9

Main index | Temporal index | Topics index | Keywords index | Graphical index | Full index


okay that's the whole thing, bestie, you're literally a STRDS neighborhood analysis main character now πŸ’–βœ¨

Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual

GRASS 8.5.0 β€” no cap, go smooth those maps πŸŽ€

πŸ“¦ where this page comes from