r.null(1grass)
π r.null β the GRASS manual page, but make it make sense π
okay bestie, welcome to r.null(1grass), a page from the GRASS User's Manual. this one is all about making NULL values (aka "no data, bestie, there is literally nothing here") behave. π«Ά
β¨ NAME β¨
r.null β manages NULL-values of a given raster map. that's it. that's the whole job. she's a specialist. π
π·οΈ KEYWORDS π·οΈ
raster, map management, null data, no-data
(so if you're searching the index, those are the vibes.)
π SYNOPSIS π
r.null
r.null --help
r.null [-fincrz] map=name [setnull=val[-val][,val[-val],...]]
[null=float] [--help] [--verbose] [--quiet] [--ui]
π Flags:
-fβ only do the work if the map is floating-point. she checks before she commits. π-iβ only do the work if the map is integer.-nβ only do the work if the map doesn't have a NULL-value bitmap file. not me gatekeeping... ok actually yes, gatekeeping.-cβ create NULL-value bitmap file, validating all data cells.-rβ remove NULL-value bitmap file. bye bestie β¨-zβ re-create NULL-value bitmap file (to compress or uncompress).--helpβ print usage summary.--verboseβ verbose module output. she tells you everything. π--quietβ quiet module output. she tells you nothing. π--uiβ force launching GUI dialog.
π§ Parameters:
map=name[required] β name of raster map for which to edit null values. yes it's required. yes you have to say which map. no she cannot read your mind.setnull=val[-val][,val[-val],...]β list of cell values to be set to NULL. yeet those numbers into the void.null=floatβ the value to replace the null value by. giving the void a glow-up. β
π DESCRIPTION π
the whole function of r.null is to explicitly create the NULL-value bitmap file. the intended usage is to update maps that do not have a NULL-value bitmap file β i.e. to indicate for each pixel if zero is a valid value, or is to be considered as NULL, i.e. a no data value. lowkey this matters so much. π§
important: the module does not work with reclassified or external maps. nope. not happening. π«
the design is flexible, periodt. ranges of values can be set to NULL, and/or the NULL value can be eliminated and replaced with a specified value.
the setnull parameter is used to specify values in the ranges to be set to NULL. a range is either a single value (e.g., 5.3), or a pair of values (e.g., 4.76-34.56). existing NULL-values are left NULL, unless the null argument is requested. she respects existing NULLs. iconic behaviour honestly. π
the null parameter eliminates the NULL value and replaces it with value. this argument is applied only to existing NULL values, and not to the NULLs created by the setnull argument. read that again bestie, it's the plot twist. π₯
π NOTES π
heads up: the value is restricted to integer if the map is an integer map. no decimals for the integer girlies. π
πΈ r.null and reclassified maps πΈ
r.null does not support reclassified maps, because if r.null was run on the reclass raster it would alter the original and any other reclass rasters of the original. so basically it would be messy and we don't do messy. therefore r.null does not allow recoding reclassified maps (products of r.reclass).
as a workaround, the way to recode such a map is: the user creates a raster map out of the reclassified map by copying it:
r.mapcalc "newmap = reclass"
there you go, problem solved, slay. β¨
π¦ NULL data compression π¦
by default no data files (i.e., NULL files) are not compressed unless a specific environment variable is set. the NULL file compression must be explicitly turned on with export GRASS_COMPRESS_NULLS=1.
Warning: such raster maps can then only be opened with GRASS GIS 7.2.0 or later. do NOT forget this, bestie, this is a real one. π
NULL file compression can be managed with r.null -z.
π External maps π
from the r.external documentation: GDAL-linked (r.external) maps do not have or use a NULL bitmap, hence r.null cannot manipulate them directly. here NULL cells are those whose value matches the value reported by the GDALGetRasterNoDataValue() function.
to introduce additional NULL values to a computation based on a GDAL-linked raster, the user needs to either create a mask with with r.mask and then "apply" it using e.g. r.resample or r.mapcalc, or use r.mapcalc to create a copy with the appropriate categories changed to NULL (if() condition).
π₯ EXAMPLES π₯
set specific values of a classified map to NULL:
r.null map=landcover.30m setnull=21,22
set NULL-values of a map to a specific value:
r.null map=fields null=99
π SEE ALSO π
r.compress, r.support, r.quant
π AUTHOR π
U.S.Army Construction Engineering Research Laboratory
π SOURCE CODE π
available at: r.null source code (history)
latest change: Friday Mar 07 10:39:45 2025 in commit: 4b9d1a2dcde590db4ab3ba1cbbb50af2768aed25
main index | raster index | topics index | keywords index | graphical index | full index
okay that's the whole page bestie, you're officially a r.null expert π no cap. this was GRASS 8.5.0 Reference Manual, Β© 2003-2026 GRASS Development Team, and the page we just devoured was r.null(1grass) from the GRASS 8.5.0 manual. go forth and manage those NULLs responsibly ππ¦πΈ
π¦ 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