2

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?

  • Can you link to the old question? – Erica Apr 3 '15 at 10:00
  • I think this should be made a duplicate of gis.stackexchange.com/questions/110139/… As some quick advice I think that it would have been better to suggest an edit to the earlier unanswered question that provided additional details into it. However, this can get messy so as a new user it may be better to leave your question open for now to see whether any answers and/or comments lead to a better way forward. – PolyGeo Apr 3 '15 at 11:13
1

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?
  • Thanks for your time! I'm glad to know it works with large width (but 31min!). The precisions you requested: 1. The 200 size I use is the diameter. 2. I use QGis (2.4), not Grass directly. In QGis, r.neighbors let me use a default setting for the Grass region. 3. My data come from Aster Gdem, clipped to the borders of my administrative region. 4. I just quoted the Old Question, to keep a sort of link. I don't use Arcgis, sorry for the misleading, but remember that it seemed "faster". Finally, for the 0s, I have no cell with value 0 in my original data. And that is now what I'm trying to fix. – TKO Apr 3 '15 at 15:46
  • ASTER GDEM is 30 meter resolution elevation data. So you are doing a neighborhood analysis of elevation data over a radius of 3 kilometers ?? – Micha Apr 4 '15 at 16:26
  • Yes. Does it sound awkard to you? I mean regarding the use of r.neighbors. – TKO Apr 7 '15 at 11:40
  • I don't know if "awkward" is the right word. It just seems unusual to create new rasters with values that represent the minimum and maximum somewhere in a 3 km vicinity. For example, if you are at a pixel near a mountain peak, the max raster at that pixel would have the value of the nearby peak, but the min would have a value from a valley 1000's of meters away. – Micha Apr 7 '15 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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