[Numpy-discussion] creating zonal statistics from two arrays
Mon Dec 20 14:44:17 CST 2010
On 12/8/2010 9:48 AM, firstname.lastname@example.org 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:
More information about the NumPy-Discussion