[GRASS-dev] remove RasterNumpy class from pygrass

Laurent C. lrntct at gmail.com
Tue Mar 24 14:45:06 PDT 2015


Hello,

May I suggest to remove any reference to RasterNumpy in the documentation ?
I just spend some time writing a code with RasterNumpy just to realize the
class was not existing.

Thanks for the workaround.

Best regards,
Laurent


2014-12-15 6:41 GMT-06:00 Pietro <peter.zamb at gmail.com>:

> Dear all,
>
> If you are ok with that, I would like to remove the RasterNumpy class,
> as far as I aware, nobody is using it.
> So I would like to avoid to introduce a class in grass70 and remove
> the class in grass71.
> However the RasterNumpy class can be easily replaced by functions like:
>
> {{{
> def raster2numpy(rastname):
>     """Return a numpy array from a raster map"""
>     with RasterRow(rastname, mode='r') as rast:
>         return np.array(rast)
>
>
> def numpy2raster(array, mtype, rastname):
>     """Save a numpy array to a raster map"""
>     reg = Region()
>     if (reg.rows, reg.cols) != array.shape:
>         msg = "Region and array are different: %r != %r"
>         raise TypeError(msg % ((reg.rows, reg.cols), array.shape))
>     with RasterRow(rastname, mode='w', mtype=mtype) as new:
>         newrow = Buffer((array.shape[1],), mtype=mtype)
>         for row in array:
>             newrow[:] = row[:]
>             new.put_row(newrow)
> }}}
>
> Any concern on this?
>
> Best regards
>
> Pietro
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20150324/0821b0c3/attachment.html>


More information about the grass-dev mailing list