TransWikia.com

Old question without answer: R.Neighbors with large neighborhoods?

Geographic Information Systems Asked by TKO on March 31, 2021

I’m working on the same theme as User 32882, and I’m new here.
I have the same problem, and update his question with more details.

Old question: “I’m running into problems running the r.neighbors GRASS command in QGIS. Although it will run for small neighborhoods as soon as I increase my neighborhood above a certain number it becomes unbearably slow. I don’t understand why Focal Statistics on Arcmap will do this in the blink of an eye while R.Neighbors takes ages?”
Link of Old question:
R.Neighbors with large neighborhoods?

Details:
We are exploring a circular neighborood of ~200 pixels.
And trying to compute Maximum or Minimum statistics.
Moreover, Maximum computation seems ok, but Minimum often presents 0 results.
Why is so slow in QGis?
What can I do to make it run faster?

One Answer

WHen you mention 200 pixels, do you mean a neighborhood of 200 pixels width? or a neighborhood that contains 200 pixels? The GRASS r.neighborhood command takes a "size" parameters which is the width of the window. So for the second case, a circular window containing 200 pixels then the width will be about:

2 x sqrt(area/pi) or ~17. 

I tried some tests as follows:

In GRASS 7.0 I created a 20 million cell raster of random values. Then I tried r.neighbors with two size parameters: 201 and 17. And for both sizes I used both the minimum and maximum methods to calculate the new rasters.

Using the very large 200 pixel neighborhood, both processes took nearly the same time, 31 minutes. This neighborhood contains about:

pi x (100^2) or 31,417 cells

Using the size parameter 17 (a neighborhood containing about 200 pixels) then each process finished in about 15 seconds. And I got values for both min and max r.neighborhood output rasters.

So I can not verify your claim that method=minimum gives zero result (maybe within your 200 pixel windows there is always at least one cell with value 0??)

Also, as to runtime, I don't know if 30 minutes is "takes ages".

Regarding ArcGIS, note that the width parameter for FocalStatistics is radius, not the same as size in GRASS. And you can specify in Arc that the radius is map units. Can you verify what parameters you are using in Arc?

I'm sure someone can offer a better explanation if you can :

  1. explain what size of neighborhood you mean
  2. what are your GRASS region settings?
  3. What are the data in the original raster like?
  4. and what exactly are the functions you are running in GRASS vs ArcGIS?

Answered by Micha on March 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP