[Numpy-discussion] creating zonal statistics from two arrays

Matt Gregory matt.gregory at oregonstate.edu
Mon Dec 20 15:44:17 EST 2010

On 12/8/2010 9:48 AM, josef.pktd at gmail.com wrote:
> Just a thought since I'm not doing spatial statistics.
> If you can create (integer) labels that assigns each point to a zone,
> then you can treat it essentially as a 1d grouped data, and you could
> use np.bincount to calculate some statistics, or alternatively
> scipy.ndimage.measurements for some additional statistics.
> This would avoid any python loop, but require a full label array.


The measurements module did the trick; thanks for the pointer.  I just 
stumbled across a very similar thread on the scipy listserv that you 
answered basically the same question with some nice code (sorry for the


BTW, the OP on that thread (Jose Gomez-Dans) has a script out there for 
doing just this type of operation that I was after:


thanks, matt

More information about the NumPy-Discussion mailing list