[GRASS-user] Re: Limit r.fillnulls to interpolate only small gaps

William Kyngesburye woklist at kyngchaos.com
Fri Feb 18 10:23:34 EST 2011

One thing to watch out for is shape - thin regions may have a large area, but are filled very nicely with r.fillnulls.  Masking completely by area will drop these as too large.

An idea I had a while back that I use to identify large areas considering shape, but could be extended to the inverse:

1. Use r.grow on the original DEM to grow into the null areas.  Use a distance (number of cells) that r.fillnulls can cover well, divided by 2.  I use 5, I think, to identify large areas.  The grow will eat up the small areas.

2. Pull out these large null areas with r.mapcalc.

3. r.grow the large nulls raster the same distance.  This is where I stopped for identifying large nulls.  The shapes may not be the same as the original null areas.  You could grow an extra half a cell before the next step to make sure there are no slivers left.

4. combine the DEM with the large null raster to identify the leftover small nulls, which you use as the mask for r.fillnulls.

There may be a better way with other GRASS modules, but it works for what I originally needed to do.

On Feb 18, 2011, at 8:45 AM, LeeDaniel wrote:

> I would do it like this:
> - Make a mask of the gaps with r.mask (either by masking placeholder values
> that stand for gaps or, if the map really has no values where there are
> gaps, by making an inverse mask from the real values.
> - Create an arbitrary raster that overlays the gaps (with the mask applied
> just use e.g. "r.mapcalc newmap=1"
> - Remove the mask
> - Conver the raster to vectors
> - Delete all vectors that are small enough to be interpolated over
> - Conver the vectors back into raster
> - Interpolate all the gaps in the old map
> - Make an inverse mask from the raster that holds the locations of the too
> large gaps
> - Use r.mapcalc to remove the interpolated areas where the gap was too big
> Another way, which is in my opinion better and faster, would be to use
> r.clump on the raster of the gaps to give the contigious areas an identical
> value, then run r.stats to spit out their areas, and then reclass the raster
> so that the cell values match the area covered by the gaps. Then you could
> remove the too big areas with r.reclass.
> Hope that helps! :)
> Daniel
> -- 
> View this message in context: http://osgeo-org.1803224.n2.nabble.com/Limit-r-fillnulls-to-interpolate-only-small-gaps-tp6040101p6040155.html
> Sent from the Grass - Users mailing list archive at Nabble.com.
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user

William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>

First Pogril: Why is life like sticking your head in a bucket filled with hyena offal?
Second Pogril: I don't know.  Why IS life like sticking your head in a bucket filled with hyena offal?
First Pogril: I don't know either.  Wretched, isn't it?

-HitchHiker's Guide to the Galaxy

More information about the grass-user mailing list