0

For the parameters whose values are log-normally distributed, we should calculate the geometric mean rather than arithmetic mean. In the Focal Statistics, there is option to calculate the arithmetic mean but I am interested to calculate the the geometric mean of my raster file. Is there any way to calculate the geometric mean of a raster in ArcGIS?

I want to calculate geometric mean of the surrounding neighborhood. The same way focal statistics calculate the arithmetic mean with defined map unit.

0
1

Based on this answer, just calculate the log, then the arithmetic mean, then the exponent. You can do this in the raster calculator with something like:

Exp(FocalStatistics(Ln(your_raster), your_neighbourhood, "MEAN")) 
4
  • How do you define neighborhood?
    – FelixIP
    Jun 1 '20 at 5:29
  • @FelixIP However you want. Circle, rectangle, annulus, kernel file, directional. It's all in the help for focal statistics. I saw no need to explain as the question wasn't about focal neighbourhoods.
    – user2856
    Jun 1 '20 at 5:47
  • First step is correct. Next should be exponent of mean cell value from output raster .Single number, not a raster of unknown neighborhood.
    – FelixIP
    Jun 1 '20 at 6:53
  • It is a single number. It's the mean value of the neighbourhood pixels. I take the question to be asking for a focal geometric mean, not a geometric mean of the entire raster, otherwise why would the question reference focal statistics?
    – user2856
    Jun 1 '20 at 8:09
1

You'll need to use script:

import numpy as np
iterable = arcpy.RasterToNumPyArray("DEM",nodata_to_value=np.NaN)
nan_array = np.isnan(iterable)
not_nan_array = ~ nan_array
a = iterable[not_nan_array]
A = np.log(a)
b = A.sum()/len(A)
print np.exp(b)

credits to this post author.

2
  • The OP has clarified the question and wants a geometric mean of a focal neighbourhood, not a geometric mean of the raster.
    – user2856
    Jun 2 '20 at 6:28
  • @user2856 I see, you were right. What I still struggle to understand is log-normal distribution near cell. Hope asker knows what he really wants.
    – FelixIP
    Jun 2 '20 at 7:29

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.