I am running

r.neighbors --overwrite --verbose input=bf03pits@PERMANENT output=bf03pitsdenoise method=mode size=5

in the GRASS GUI using the r.neighbors dialog.

bf03pits has 3955848 all with values either 0 or 1.

When I run r.neighbors the result has 1 cell with a range of -nan to -nan.

Yet the output shows no errors.

Why might r.neighbors be failing? How can I go about doing what I want?

  • Have you set the region to match your input raster? i.e. g.region rast=bf03pits
    – si_2012
    Mar 15, 2013 at 1:00
  • @si_2012, that was absolutely the problem. Please write your comment up as an answer so I can accept it. Was there some obvious way I should have known that?
    – Richard
    Mar 15, 2013 at 4:30
  • 2
    Answer written up. There's no obvious way to know this, but with Grass its essential to pay close attention to the region settings. Before running commands, type g.region -p in the command line to make sure the settings are as you expect.
    – si_2012
    Mar 15, 2013 at 9:07

2 Answers 2


In Grass, this sort of problem occurs when the region settings don't match the input raster. Try setting the region to the input raster, i.e. g.region rast=bf03pits, before running r.neighbors.


In GRASS v. 7.x the solution is still the same (we must match region setting with the raster extent) but the option has changed : g.region raster=bf03pits

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.