[GRASS-dev] problem using pygrass

Javier Martínez-López javi.martinez.lopez at gmail.com
Wed Mar 5 10:16:33 PST 2014


Dear Pietro,

the issue is apparently not related to the GRASS build but to the fact
that when there is a mask on the region, the areas outside it are
converted to "nan" in the numpy matrix when the map is FCELL, and to
the value "-2147483648" when the map is CELL... at least for me! I
need to apply a mask because I intend to set up an iterative process
in different regions, but I guess it can be just solved by filtering
the matrix before the analysis. I am uploading the code to a github
repo [1], just in case anyone is interested or it could serve as an
example.

Thank you and cheers,

Javier

[1] https://github.com/javimarlop/eHab_grasspy

On Wed, Mar 5, 2014 at 12:15 PM, Pietro <peter.zamb at gmail.com> wrote:
> Hi Javier,
>
> On Wed, Mar 5, 2014 at 10:33 AM, Javier Martínez-López
> <javi.martinez.lopez at gmail.com> wrote:
>> ... something is wrong with my installation... I cannot even open any
>> map from the NC dataset using build 59147, getting the following error
>> after interrupting the idle process [1], while doing it with version
>> 57982 works fine... any idea or advice? Here is the built
>> configuration that was used for the 59147 version:
>
> [cut]
>
>> the only difference is "--with-lapack" in the upper one...is there
>> something wrong with it?
>
> I don't think so, I'm using this flag too.
>
> Try to build everything from scranch, with:
>
> make distclean
> ./configure blabla
> make -j4
>
> I've run your code using the current svn version (r59193) and it is
> working on my laptop.
> The only thing is that the region in my case is set to the elevation
> raster map, so the shape is different:
>
> In [1]: import numpy as np
>
> In [2]: import grass.pygrass as pygrass
>
> In [3]: lu = pygrass.raster.RasterNumpy('landuse')
>
> In [4]: lu.shape
> Out[6]: (1350, 1500)
>
> In [5]: lu.open()
>
> In [6]: lu[:4, :3]
> Out[6]:
> RasterNumpy([[5, 5, 5],
>        [5, 5, 5],
>        [5, 5, 5],
>        [5, 3, 3]], dtype=int32)
>
> In [7]: lu.close()


More information about the grass-dev mailing list