On Mon, Apr 11, 2011 at 1:17 PM, David Crisp <[email protected]> wrote:
> On Mon, Apr 11, 2011 at 11:00 AM, Sturla Molden <[email protected]> wrote:
>> Den 11.04.2011 02:01, skrev David Crisp:
>>> Can anybody guide me through this problem?

I dont know how acceptable it is to answer your own question :P   here goes:

TO some extent I have solved my problem,  But I am unsure if it is the
correct way of solving it:

for each_line in point_scandata:
        matrix_x = round_to_value((each_line[0]-x_offset),horizontal_precision)
        matrix_y = round_to_value((each_line[1]-y_offset),horizontal_precision)
        if vegetation_matrix[matrix_x,matrix_y] == None:
                vegetation_matrix[matrix_x,matrix_y] = Record()
        vegetation_matrix[matrix_x,matrix_y].add(each_line[2])

I added the IF check.  If vegetation_matrix[matrix_x,matrix_y] is
still equal to None then that means the record for that grid cell has
not been created yet.
So if it IS none then simply create a record.

If vegetation_matrix[matrix_x,matrix_y] is NOT None then the only
other value it could be is Record (Major Assumption that nobody else
has fiddled with the code)  and so simply add a new value to the
record with the appropriate value.

It works but is it the correct way of doing things...

Regards,
David
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to