I have to calculate the weighted average of a raster file and I have to use a different weight in each grid cell (for which I have an ASCII file).

If I had a constant weight, I would use the raster calculator. However, I am not sure how to calculate it with this. Would it make sense to just multiply the two raster files and then divide it by the weights (i.e. replicate the weighted avg formula manually)?

closed as too broad by ahmadhanb, Jochen Schwarze, nmtoken, Andre Silva, xunilk Jan 10 at 21:26

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Why a different weight for each cell? Please explain more about what you're tying to achieve... it's possible that what you need is a bunch of Con statements with the different weight kernels then combine the intermediate rasters (sum or mosaic) but it's a bit vague what you're trying to do here. – Michael Stimson Jan 10 at 6:44
  • @MichaelStimson I am trying to calculate a weighted average, using as weights the values of the area of each cell. The area of each cell is provided by the original authors as a txt file. (trying to replicate the data from diegopuga.org/data/rugged/#country) – tish Jan 10 at 6:56
  • Aren't the areas of each cell the same? A raster cannot have differing cell sizes throughout unless you take slope into account in which case the value becomes ground surface area which once calculated is a constant. – Michael Stimson Jan 10 at 7:02
  • 1
    what is the projection that you are using. I is indeed necessaray to compensate the area of the pixels if you don't work with an equal area projection on large extents, but locally you can neglect it. – radouxju Jan 10 at 7:20
  • 1
    As a normalization I can understand why; I would create a terrain with the minimum and maximum values (and a few others if needed) drawn in as straight lines, convert the terrain to a raster and then use the generated raster to normalize your data though as @radouxju said I can't see why you would need to if your're working with projected data. It seems the normalization is only for working with geographic data where the projection of each cell to determine area is trapezoidal rather than rectangular. – Michael Stimson Jan 10 at 7:29