Hi Pierre,

On Mon, Dec 17, 2012 at 7:48 AM, Pierre Roudier

<pierre.roudier@gmail.com> wrote:

Hi,

I am using (with enthusiasm!) Pietro's pygrass library to develop a raster

module. I am using Numpy/Scipy as my working horse, so I manipulate a lot of

the RasterNumpy objects that have been introduced with pygrass.

I'm really happy that you are using the pygrass library!

In a specific step, I am identifying pixels using a test (this would be

similar to my_array < 100). I would like to extract the points that satisfy

the test, and access not only their values and index in the array, but I

would also go back to their coordinates to extract them as (x, y, z).

Is there a way to do this using RasterNumpy and pygrass?

yes, you should use the numpy stuff, something like:

import numpy as np

a = np.arange(15).reshape(3, 5)

a

array([[ 0, 1, 2, 3, 4],

[ 5, 6, 7, 8, 9],

[10, 11, 12, 13, 14]])

b = a>7

b1

array([[False, False, False, False, False],

[False, False, False, True, True],

[ True, True, True, True, True]], dtype=bool)

b.nonzero() # return two array with x and y and z if the array is 3D

(array([1, 1, 2, 2, 2, 2, 2]), array([3, 4, 0, 1, 2, 3, 4]))

Please let me know if you find something that is not clear, or is not

working properly...

All the best!

Pietro