TransWikia.com

Getting multiple highest values using Cell Statistics in ArcGIS Pro

Geographic Information Systems Asked on February 14, 2021

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?

One Answer

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)]

Correct answer by Aaron on February 14, 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