On Thu, Sep 20, 2012 at 1:28 PM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > Expanding on what MRAB wrote, since you probably have far fewer > categories than pixels, you may be able to take better advantage of > numpy's vectorized operations (which are pretty much the whole point > of using numpy in the first place) by looping over the categories > instead: > > for cat in categories: > totals[cat] += np.sum(valuesCategory * (valuesRaster == cat))
Of course, that should have read: for cat in categories: totals[cat] += np.sum(valuesRaster * (valuesCategory == cat)) -- http://mail.python.org/mailman/listinfo/python-list