r.object.geometry(1grass)

✨ r.object.geometry ✨

okay bestie, gather round, because r.object.geometry from the GRASS User's Manual is literally about to give your raster objects a full geometry glow-up πŸ’…

🌸 NAME 🌸

r.object.geometry β€” it calculates geometry parameters for raster objects. that's it, that's the whole job, and it eats πŸ’–

πŸŽ€ KEYWORDS πŸŽ€

raster, statistics, reclass, clumps


πŸ¦‹ SYNOPSIS πŸ¦‹

r.object.geometry
r.object.geometry --help
r.object.geometry [-m] input=name  [output=name]   [separator=character]
format=name  [--overwrite]  [--help]  [--verbose]  [--quiet]  [--ui]

⭐ Flags ⭐

  • -m β€” use meters as the units instead of cells. metric queen behavior.
  • --overwrite β€” let your output files just overwrite existing files, no cap.
  • --help β€” prints the usage summary so you're not out here confused.
  • --verbose β€” verbose module output, i.e. it tells you everything.
  • --quiet β€” quiet module output. shhh 🀫
  • --ui β€” force launching the GUI dialog, for the visual girlies.

🌈 Parameters 🌈

  • input=name [required] β€” name of the input raster map. mandatory bestie, no skipping.
  • output=name β€” name for the output file.
  • separator=character β€” field separator. special characters you can use: pipe, comma, space, tab, newline. default is pipe. ngl the pipe default is iconic.
  • format=name [required] β€” output format. options: plain, json. default: plain.
    • plain: plain text output, the classic.
    • json: JSON (JavaScript Object Notation), for when you want to be fancy 🫢

πŸ’– DESCRIPTION πŸ’–

r.object.geometry calculates form statistics of raster objects in the input map, and writes it all out to the output text file β€” or to standard output if you don't give an output filename, or if you give - β€” with the fields separated by whatever separator you chose. no gatekeeping here.

Objects are defined as clumps of adjacent cells with the same category value (so like, the output of r.clump or i.segment). adjacent + same category = one object, periodt.

By default, values are in pixels. if you want values in meters, you set the -m flag. and fr fr, if your current working region is in lat-long or has non-square pixels, using meters is recommended β€” trust, you want that.

the statistics currently calculated are exactly the same as in v.to.db (except for compact_square and mean coordinates, okurrr):

  • area
  • perimeter
  • compact_square β€” compactness compared to a square: compact_square = 4 * sqrt(area) / perimeter
  • compact_circle β€” compactness compared to a circle: compact_circle = perimeter / ( 2 * sqrt(PI * area) )
  • fractal dimension β€” fd = 2 * ( log(perimeter) / log(area + 0.001) )
  • mean x coordinate of object (in map units)
  • mean y coordinate of object (in map units)

πŸ”₯ EXAMPLE πŸ”₯

watch this:

g.region raster=soilsID
r.object.geometry input=soilsID output=soils_geom.txt

and the format=json option can be used to change the output format to JSON:

r.object.geometry input=zipcodes format=json
[
    {
        "category": 1,
        "area": 106,
        "perimeter": 62,
        "compact_circle": 1.6987670351864215,
        "compact_square": 0.66423420264432265,
        "fd": 1.7699924681225903,
        "mean_x": 631382.07547169807,
        "mean_y": 222764.15094339623
    },
    {
        "category": 2,
        "area": 57,
        "perimeter": 36,
        "compact_circle": 1.3451172460704992,
        "compact_square": 0.83887049280786108,
        "fd": 1.772672742164326,
        "mean_x": 643460.52631578944,
        "mean_y": 217232.45614035087
    },
    {
        "category": 3,
        "area": 10,
        "perimeter": 16,
        "compact_circle": 1.4272992929222168,
        "compact_square": 0.79056941504209488,
        "fd": 2.4081353865496951,
        "mean_x": 631300,
        "mean_y": 215450
    },
    {
        "category": 4,
        "area": 63,
        "perimeter": 60,
        "compact_circle": 2.1324361862292305,
        "compact_square": 0.52915026221291817,
        "fd": 1.9764401337147652,
        "mean_x": 642345.23809523811,
        "mean_y": 226599.20634920636
    },
    {
        "category": 5,
        "area": 491,
        "perimeter": 156,
        "compact_circle": 1.9859985189304281,
        "compact_square": 0.56816717451693177,
        "fd": 1.6299200778082998,
        "mean_x": 637912.93279022397,
        "mean_y": 220636.96537678209
    },
    {
        "category": 6,
        "area": 83,
        "perimeter": 60,
        "compact_circle": 1.8578355639603314,
        "compact_square": 0.60736223860961991,
        "fd": 1.8531256328449071,
        "mean_x": 635846.38554216863,
        "mean_y": 227219.8795180723
    }
]

look at that JSON format. literally so clean πŸ’€βœ¨


🌸 SEE ALSO 🌸

i.segment, r.clump, v.to.db

go read those too, they're all friends 🫢

πŸ‘‘ AUTHORS πŸ‘‘

  • Moritz Lennert
  • Markus Metz (diagonal clump tracing)

πŸ’œ SOURCE CODE πŸ’œ

Available at: r.object.geometry source code (history)

latest change: Thursday Nov 06 22:27:54 2025 in commit: 298b38614712934179355ea767403d6bfea8f5f9

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, you're officially a r.object.geometry expert πŸ’…βœ¨ this was GRASS 8.5.0, and yes the copyright is literally Β© 2003-2026 GRASS Development Team because the GRASS Development Team stays booked and busy πŸ’– see you in the next manpage, mwah πŸŽ€

πŸ“¦ where this page comes from