v.fill.holes(1grass)

πŸ’– v.fill.holes πŸ’–

okay bestie, gather round, because we're talking about v.fill.holes β€” that's the GRASS manual page, and it's literally the "fill holes in areas by keeping only outer boundaries" girlie. she's from the GRASS User's Manual and she is so good at what she does. no cap. πŸ•³οΈβž‘οΈβœ¨


✨ KEYWORDS ✨

vector, geometry, fill, exterior, ring, perimeter πŸŽ€


🌸 SYNOPSIS 🌸

v.fill.holes
v.fill.holes --help
v.fill.holes input=name  [layer=string]   [cats=range]
[where=sql_query]  output=name  [--overwrite]  [--help]  [--verbose]
[--quiet]  [--ui]

πŸŽ€ Flags πŸŽ€

  • --overwrite β€” bestie this lets your output files just overwrite existing files. rude but useful πŸ’…
  • --help β€” prints the usage summary, aka the cheat sheet 🫢
  • --verbose β€” verbose module output, she's chatty, she tells you everything πŸ‘‘
  • --quiet β€” quiet module output, she says nothing, she's mysterious πŸ¦‹
  • --ui β€” force launching the GUI dialog, for when you want the pretty buttons ✨

🌈 Parameters 🌈

  • input=name [required] β€” Name of input vector map. Or, plot twist, the data source for direct OGR access 😌
  • layer=string β€” Layer number or name. so like, vector features can have category values in different layers, and this number decides which layer to use. when you're doing direct OGR access, this is the layer name instead. Default: 1 ⭐
  • cats=range β€” Category values. Example: 1,3,7-9,13 πŸ“
  • where=sql_query β€” WHERE conditions of SQL statement, no where keyword needed. Example: income < 1000 and population >= 10000 πŸ’œ
  • output=name [required] β€” Name for output vector map πŸŽ€

πŸ’… DESCRIPTION πŸ’…

okay so v.fill.holes fills empty spaces inside areas. specifically β€” and this is the important part β€” it preserves areas that have centroids, while areas without centroids (which typically represent holes) get removed. periodt. πŸ•³οΈβŒ

the way that it works: v.fill.holes goes over all areas in a vector map and preserves only the outer boundaries of each area, while removing inner boundaries which are considered holes. the holes become part of the area which contained them. and listen β€” no boundaries of these holes are preserved. none. zero. gone. 😀

Figure: Holes inside areas are removed. (a) Original areas with holes and (b) the same areas but with holes filled. πŸ–ΌοΈ

so here's a lil situation that might trip you up: in case areas have empty space in between them, i.e., there are holes in the overall coverage, but not in the areas themselves β€” v.fill.holes can't assign this empty space to either of these areas, because it does not know which area this empty space should belong to. tragic, ik. 😭

if that space genuinely needs to be filled, you resolve it by merging the areas around the empty space into one, by dissolving their common boundaries. this turns the empty space into a hole inside one single area, which turns the whole situation into a case of one area with a hole. slay, problem solved. πŸ’–

Figure: Empty space in between two areas does not belong to either area, so it is filled only after the boundaries between areas are dissolved, i.e., areas merged into one. (a) Original areas with space in between, (b) one area with a hole after dissolving the common boundary, and (c) hole filled. πŸ–ΌοΈ

πŸ¦‹ Topology πŸ¦‹

strictly speaking β€” and nerd hat ON β€” in the GRASS topological model, an area is a closed boundary (or a series of connected closed boundaries) which may have a centroid. 🧚

if it has a centroid, it is rendered as a filled area in displays, and this is what is usually considered an area from the user perspective. these are the areas where v.fill.holes preserves the associated outer boundary (or boundaries). πŸ’«

other closed boundaries, i.e., those without a centroid, are not carried over to the output. and all other features are removed too, including points and lines. no survivors, bestie. πŸ’€

🌈 Attributes 🌈

if a specific layer is selected, attributes for that layer are preserved for the areas, based on the category or categories associated with each area. by default, layer number 1 is selected. ⭐

in case there are attribute tables associated with other layers, or attributes associated with categories of other features than areas with centroids β€” this attribute data is not carried over to the output, just like the corresponding geometries. it's giving "you lose what you don't bring" 🌸


πŸ“ EXAMPLE πŸ“

the lakes vector map in the North Carolina sample dataset represents islands inside lakes as areas distinguished by attributes. to demonstrate v.fill.holes, we will first extract only the lakes, which will create holes where the islands were located. then we'll fill the holes created in the lakes to get the whole perimeter of the lakes including islands. 🏞️

remove the islands by extracting everything else (results in holes):

v.extract input=lakes where="FTYPE != 'ROCK/ISLAND'" output=lakes_only

remove the holes:

v.fill.holes input=lakes_only output=lakes_filled

Figure: The filled lake (blue) and borders of the original lakes with islands removed (light blue). Figure shows a smaller area in the north of the data extent. πŸ–ΌοΈ


πŸ‘€ SEE ALSO πŸ‘€

  • v.dissolve for removing common boundaries based on attributes, πŸ’…
  • v.clean for removing topological issues, 🧼
  • r.fillnulls for filling empty spaces in raster maps using interpolation, 🌊
  • r.fill.stats for filling empty spaces in raster maps using statistics. πŸ“Š

πŸ‘‘ AUTHOR πŸ‘‘

Vaclav Petras, NCSU Center for Geospatial Analytics, GeoForAll Lab 🌟


πŸ’– SOURCE CODE πŸ’–

Available at: v.fill.holes source code (history)

Latest change: Friday Jun 20 15:13:04 2025 in commit: 9dd92f956684722d9ad0ff5f3e724b92cb8e1a5b πŸ•

Main index | Vector index | Topics index | Keywords index | Graphical index | Full index πŸ—‚οΈ


okay and that's the whole page, bestie!! 🫢 GRASS 8.5.0, Β© 2003-2026 GRASS Development Team, straight outta the GRASS 8.5.0 Reference Manual β€” mwah, iconic, no notes. πŸ’‹πŸŽ€βœ¨

πŸ“¦ where this page comes from