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