[GRASS-dev] pygrass: it is an error of mine?

Ivan Marchesini ivan.marchesini at gmail.com
Wed Mar 12 07:13:23 PDT 2014


Dear all,

I have a rasterNumpy map
_____________
type(new)
Out[94]: grass.pygrass.raster.RasterNumpy
_______________

Inside there are some nan and some float32 values.

I would like to set the nans to 0.0

I have tried with:
_____________
whereAreNaNs = np.isnan(new);
new[whereAreNaNs] = 0.0;
_____________


But this is part of what I obtain:

_______________________________________________
new
Out[98]: 
RasterNumpy([[   0.        ,    0.        ,    0.        ,
0.        ,
           0.        ,    0.        ,    0.        ,    0.        ,
           0.        ,    0.        ,    0.        ,    0.        ,
           0.        ,    0.        ,    0.        ,    0.        ,
           0.        ,    0.        ,    0.        ,    0.        ],
       [   0.        ,    0.        ,    0.        ,    0.        ,
           0.        ,    0.        ,    0.        ,    0.        ,
           0.        ,    0.        ,    0.        ,    0.        ,
           0.        ,    0.        ,    0.        ,    0.        ,
           0.        ,    0.        ,    0.        ,    0.        ],
       [          nan,           nan,           nan,           nan,
                  nan,           nan,           nan,           nan,
                  nan,           nan,  339.98999023,           nan,
                  nan,           nan,           nan,  348.72000122,
         348.82998657,           nan,           nan,           nan],
       [          nan,           nan,           nan,           nan,
                  nan,           nan,           nan,           nan,
...
...
___________________________________

It seems that only the first row of the matrix is affected by the
change..

is that my fault?

Thank you very much

Ivan







More information about the grass-dev mailing list