r.grow.distance(1grass)

πŸ’– r.grow.distance πŸ’–

okay bestie, welcome to r.grow.distance, a GRASS User's Manual moment brought to you by the letter "d" for distance πŸ¦‹ this one's a raster module, and it's lowkey iconic.

✨ NAME ✨

r.grow.distance β€” generates a raster map containing distances to nearest raster features and/or the value of the nearest non-null cell. πŸŽ€

πŸ”‘ KEYWORDS πŸ”‘

raster, distance, proximity β€” that's the vibe check right there ✨


🌸 SYNOPSIS 🌸

r.grow.distance
r.grow.distance --help
r.grow.distance [-mn] input=name  [distance=name]   [value=name]
[metric=string]   [minimum_distance=float]   [maximum_distance=float]
[--overwrite]  [--help]  [--verbose]  [--quiet]  [--ui]

🎏 Flags

  • -m β€” outputs distances in meters instead of map units, slay πŸ’…
  • -n β€” calculates distance to the nearest NULL cell instead
  • --overwrite β€” lets output files overwrite files that already exist, no hesitation
  • --help β€” prints the usage summary for u
  • --verbose β€” verbose module output, she's chatty
  • --quiet β€” quiet module output, she's mysterious
  • --ui β€” forces the GUI dialog to launch 🫢

🌈 Parameters

  • input=name [required] β€” name of the input raster map. not optional, bestie, she NEEDS it.
  • distance=name β€” name for the distance output raster map
  • value=name β€” name for the value output raster map
  • metric=string β€” the metric 🧚
    • Options: euclidean, squared, maximum, manhattan, geodesic
    • Default: euclidean
  • minimum_distance=float β€” minimum distance threshold
  • maximum_distance=float β€” maximum distance threshold

πŸ’« DESCRIPTION πŸ’«

r.grow.distance generates raster maps representing the distance to the nearest non-null cell in the input map and/or the value of the nearest non-null cell. that's literally the whole job and she does it flawlessly ✨


πŸ“ NOTES πŸ“

the -n flag calculates the respective pixel distances to the nearest NULL cell. noted. πŸ’€

you, the user, get to pick from five different metrics, and they control the geometry in which grown cells are created (this is all controlled by the metric parameter): Euclidean, Squared, Manhattan, Maximum, and Geodesic. five options, five vibes, choose wisely πŸ‘‘

the Euclidean distance, aka the Euclidean metric, is the "ordinary" distance between two points that you'd measure with a ruler β€” and yes, it can be proven by repeated application of the Pythagorean theorem. the formula is given by:

d(dx,dy) = sqrt(dx^2 + dy^2)

cells grown using this metric would form isolines of distance that are circular from a given point, with the distance given by the radius. it's giving perfect circles, we love to see it β­•

the Squared metric is the Euclidean distance squared, i.e. it simply omits the square-root calculation. this may be faster, and it's sufficient if you only need relative values. no square root, no problem 😌

the Manhattan metric, or Taxicab geometry, is a form of geometry in which the usual metric of Euclidean geometry is replaced by a new metric in which the distance between two points is the sum of the (absolute) differences of their coordinates. the name alludes to the grid layout of most streets on the island of Manhattan, which causes the shortest path a car could take between two points in the city to have length equal to the points' distance in taxicab geometry. πŸš• the formula is given by:

d(dx,dy) = abs(dx) + abs(dy)

where cells grown using this metric would form isolines of distance that are rhombus-shaped from a given point. rhombus era πŸ’ 

the Maximum metric is given by the formula

d(dx,dy) = max(abs(dx),abs(dy))

where the isolines of distance from a point are squares. squares!! ⬜

the Geodesic metric is calculated as geodesic distance, and it's to be used only in a latitude-longitude coordinate reference system. it's recommended to use it along with the -m flag in order to output distances in meters instead of map units. 🌍


if minimum_distance is given, all cells with a distance smaller than minimum_distance will be set to NULL. gone, poof, bye πŸ‘‹

if maximum_distance is given, all cells with a distance larger than maximum_distance will be set to NULL. the resultant output is equivalent to a buffer. πŸ›‘οΈ

if both minimum_distance and maximum_distance are given, the result will be similar to a doughnut β€” a restricted belt for a given distance range 🍩 β€” and all cells outside this distance range will be set to NULL.


πŸ“ EXAMPLES πŸ“

🌊 Distance from the streams network

North Carolina sample dataset:

g.region raster=streams_derived -p
r.grow.distance input=streams_derived distance=dist_from_streams
r.colors map=dist_from_streams color=rainbow

Euclidean distance from the streams network in meters (map subset)

Euclidean distance from the streams network in meters (detail, numbers shown with d.rast.num)

🌊 Distance from sea in meters in latitude-longitude CRS

g.region raster=sea -p
r.grow.distance -m input=sea distance=dist_from_sea_geodetic metric=geodesic
r.colors map=dist_from_sea_geodetic color=rainbow

Geodesic distances to sea in meters


πŸ‘€ SEE ALSO πŸ‘€

  • r.grow, r.distance, r.buffer, r.cost, r.patch
  • Wikipedia Entry: Euclidean Metric
  • Wikipedia Entry: Manhattan Metric

πŸ‘‘ AUTHOR πŸ‘‘

Glynn Clements β€” king behaviour, honestly πŸ’œ


πŸ“¦ SOURCE CODE πŸ“¦

Available at: r.grow.distance source code (history)

Latest change: Saturday Oct 25 22:50:58 2025 in commit: ee87f21833475fd40805f58d1702f7d64478a27b

Main index | Raster index | Topics index | Keywords index | Graphical index | Full index

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


okay that's the whole page bestie, no cap 🫢 one last thing before u go β€” this came from the r.grow.distance(1grass) page, the last touch was Saturday Oct 25 22:50:58 2025, and it's all copyrighted Β© 2003-2026 GRASS Development Team under GRASS 8.5.0 Reference Manual. periodt. πŸ’…βœ¨πŸŒˆ

πŸ“¦ where this page comes from