Hello Nicola,<div><br></div><div>I am not aware of a magical "one function" numpy solution (is there one numpy gurus?). </div><div><br></div><div>I don't know if it's optimal, but here's how I usually do similar things.</div>
<div><br></div><div>I wrote a simple function that assigns points (any number of dimensions) to a regular multi-dimensional grid. It is here: <a href="https://gist.github.com/1509853">https://gist.github.com/1509853</a> It is short, commented and should be straightforward to use.</div>
<div><br></div><div>Once you have the assignments, you can:</div><div>- get the non-empty cell indexes with `np.unique(assignments)`</div><div>- retrieve the points assigned to a cell with `points[assignments == cell_index]`</div>
<div>- iterate over assignments to select the points you want for each cell.</div><div><br></div><div>Hope this helps,</div><div><br></div><div>Adrien</div><div><br></div><div>PS: This is one of the first times I post an answer on this list, so if I did anything wrong, let me know. Numpy is such a wonderful thing and you guys do such an amazing work, that I though it is time to give back at least epsilon of what I got from you :-)<br>
<br><div class="gmail_quote">2011/12/22 Nicola Creati <span dir="ltr"><<a href="mailto:ncreati@inogs.it">ncreati@inogs.it</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I have a cloud on sparse points that can be described by a Nx3 array (N<br>
is the number of points). Each point is defined by an x, y and z coordinate:<br>
<br>
x0 y0 z0<br>
x1 y1 z1<br>
   .    .    .<br>
   .    .    .<br>
   .    .    .<br>
xn yn zn<br>
<br>
<br>
I need to bin the cloud to a regular 2D array according to a desired bin<br>
size assigning to each cell (bin) the minimum z of all points that fall<br>
in that cell(bin). Moreover I need indexes of points that fall in each<br>
cell(bin).<br>
<br>
Is there any way to accomplish this task in numpy?<br>
<br>
Thanks.<br>
<br>
Nicola Creati<br>
<br>
<br>
<br>
<br>
--<br>
Nicola Creati<br>
Istituto Nazionale di Oceanografia e di Geofisica Sperimentale - OGS <a href="http://www.inogs.it" target="_blank">www.inogs.it</a> Dipartimento di Geofisica della Litosfera Geophysics of Lithosphere Department CARS (Cartography and Remote Sensing) Research Group <a href="http://www.inogs.it/Cars/" target="_blank">http://www.inogs.it/Cars/</a> Borgo Grotta Gigante 42/c 34010 Sgonico - Trieste - ITALY <a href="mailto:ncreati@ogs.trieste.it">ncreati@ogs.trieste.it</a><br>

off.   <a href="tel:%2B39%20040%202140%20213" value="+390402140213">+39 040 2140 213</a><br>
fax.   <a href="tel:%2B39%20040%20327307" value="+39040327307">+39 040 327307</a><br>
<br>
_____________________________________________________________________<br>
This communication, that may contain confidential and/or legally privileged information, is intended solely for the use of the intended addressees. Opinions, conclusions and other information contained in this message, that do not relate to the official business of OGS, shall be considered as not given or endorsed by it. Every opinion or advice contained in this communication is subject to the terms and conditions provided by the agreement governing the engagement with such a client. Any use, disclosure, copying or distribution of the contents of this communication by a not-intended recipient or in violation of the purposes of this communication is strictly prohibited and may be unlawful. For Italy only: Ai sensi del D.Lgs.196/2003 - "T.U. sulla Privacy" si precisa che le informazioni contenute in questo messaggio sono riservate ed a uso esclusivo del destinatario.<br>

_____________________________________________________________________<br>
<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div><br></div>