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)
}}}
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.
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)
}}}