2

On my ArcGIS Pro, I have raster data of temperature of each month (from Jan to Dec) in US. Now I want to find out four warmest months, and I think I can use cell statistics tool. How can I do this calculation or is there other tool I should be using?

2

You can use RasterToNumPyArray to convert your rasters to numpy arrays and then use Numpy to extract statistics from the arrays. In this example, I extract the median value from each of the 12 arrays, add them to a dictionary, and pick out the top 4 items using Counter.

import numpy as np
from collections import Counter

# Generate some sample numpy array data
datadict = {}
months = ["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"]

for m in months:
    datadict[m] = np.random.randint(255, size=(4, 4))

# Generate a dict with variable name key and median value
d = {k:np.median(v) for k,v in datadict.items()}

# Returns the top 4 items in dict
vals = Counter(d).most_common(4) 
print(vals)

[('oct', 169.0), ('jun', 158.5), ('mar', 134.5), ('apr', 134.0)]
1
  • Thank you so much!
    – Yoshi
    Sep 21 '20 at 18:49

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.