[GRASS-user] passing raster map to Python object
Hamish
hamish_b at yahoo.com
Wed Aug 12 03:41:23 EDT 2009
Milton Cezar Ribeiro wrote:
> Thanks for your encourager's email.
> I started to play with numpy for other purposes,
> but I will give a look in deep for this.
>
> If I get success I will be happy report it here.
it should work. one thing, be sure to translate NULL cells to numpy.nan,
e.g.
>>> import numpy as np
>>> x = np.array([[1, 2, 3], [4, 5, 6]], np.float64)
>>> x
array([[ 1., 2., 3.],
[ 4., 5., 6.]])
>>> x[0,1]
2.0
>>> x[0,1] = np.nan
>>> x
array([[ 1. , nan, 3. ],
[ 4. , 5. , 6. ]])
see swig/python/examples/rasteraccess.py for reading raster row by row.
Hamish
More information about the grass-user
mailing list