|
@@ -22,7 +22,7 @@ from grass.pygrass.modules import Module
|
|
|
from grass.pygrass.utils import get_mapset_raster, findmaps
|
|
|
|
|
|
from grass.pygrass.modules.grid.split import split_region_tiles
|
|
|
-from grass.pygrass.modules.grid.patch import rpatch_map
|
|
|
+from grass.pygrass.modules.grid.patch import rpatch_map, rpatch_map_r_patch_backend
|
|
|
|
|
|
|
|
|
def select(parms, ptype):
|
|
@@ -424,11 +424,17 @@ class GridModule(object):
|
|
|
:type split: bool
|
|
|
:param mapset_prefix: if specified created mapsets start with this prefix
|
|
|
:type mapset_prefix: str
|
|
|
+ :param patch_backend: "r.patch", "RasterRow", or None for for default
|
|
|
+ :type patch_backend: None or str
|
|
|
:param run_: if False only instantiate the object
|
|
|
:type run_: bool
|
|
|
:param args: give all the parameters to the command
|
|
|
:param kargs: give all the parameters to the command
|
|
|
|
|
|
+ When patch_backend is None, the RasterRow method is used for patching the result.
|
|
|
+ When patch_backend is "r.patch", r.patch is used with nprocs=processes.
|
|
|
+ r.patch can only be used when overlap is 0.
|
|
|
+
|
|
|
>>> grd = GridModule('r.slope.aspect',
|
|
|
... width=500, height=500, overlap=2,
|
|
|
... processes=None, split=False,
|
|
@@ -458,6 +464,7 @@ class GridModule(object):
|
|
|
start_col=0,
|
|
|
out_prefix="",
|
|
|
mapset_prefix=None,
|
|
|
+ patch_backend=None,
|
|
|
*args,
|
|
|
**kargs,
|
|
|
):
|
|
@@ -474,6 +481,20 @@ class GridModule(object):
|
|
|
self.out_prefix = out_prefix
|
|
|
self.log = log
|
|
|
self.move = move
|
|
|
+ # by default RasterRow is used as previously
|
|
|
+ # if overlap > 0, r.patch won't work properly
|
|
|
+ if not patch_backend:
|
|
|
+ self.patch_backend = "RasterRow"
|
|
|
+ elif patch_backend not in ("r.patch", "RasterRow"):
|
|
|
+ raise RuntimeError(
|
|
|
+ _("Parameter patch_backend must be 'r.patch' or 'RasterRow'")
|
|
|
+ )
|
|
|
+ elif patch_backend == "r.patch" and self.overlap:
|
|
|
+ raise RuntimeError(
|
|
|
+ _("Patching backend 'r.patch' doesn't work for overlap > 0")
|
|
|
+ )
|
|
|
+ else:
|
|
|
+ self.patch_backend = patch_backend
|
|
|
self.gisrc_src = os.environ["GISRC"]
|
|
|
self.n_mset, self.gisrc_dst = None, None
|
|
|
if self.move:
|
|
@@ -665,16 +686,28 @@ class GridModule(object):
|
|
|
for otmap in self.module.outputs:
|
|
|
otm = self.module.outputs[otmap]
|
|
|
if otm.typedesc == "raster" and otm.value:
|
|
|
- rpatch_map(
|
|
|
- otm.value,
|
|
|
- self.mset.name,
|
|
|
- self.msetstr,
|
|
|
- bboxes,
|
|
|
- self.module.flags.overwrite,
|
|
|
- self.start_row,
|
|
|
- self.start_col,
|
|
|
- self.out_prefix,
|
|
|
- )
|
|
|
+ if self.patch_backend == "RasterRow":
|
|
|
+ rpatch_map(
|
|
|
+ raster=otm.value,
|
|
|
+ mapset=self.mset.name,
|
|
|
+ mset_str=self.msetstr,
|
|
|
+ bbox_list=bboxes,
|
|
|
+ overwrite=self.module.flags.overwrite,
|
|
|
+ start_row=self.start_row,
|
|
|
+ start_col=self.start_col,
|
|
|
+ prefix=self.out_prefix,
|
|
|
+ )
|
|
|
+ else:
|
|
|
+ rpatch_map_r_patch_backend(
|
|
|
+ raster=otm.value,
|
|
|
+ mset_str=self.msetstr,
|
|
|
+ bbox_list=bboxes,
|
|
|
+ overwrite=self.module.flags.overwrite,
|
|
|
+ start_row=self.start_row,
|
|
|
+ start_col=self.start_col,
|
|
|
+ prefix=self.out_prefix,
|
|
|
+ processes=self.processes,
|
|
|
+ )
|
|
|
noutputs += 1
|
|
|
if noutputs < 1:
|
|
|
msg = "No raster output option defined for <{}>".format(self.module.name)
|