Bug report #18167

I have a modification to make r.mapcalc (grass7/processing toolbox) work with windows 7 and QGIS Master (2.99...)

Added by Olivier ATHIMON over 2 years ago. Updated almost 2 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Processing/GRASS
Affected QGIS version:master Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:26058

Description

Hi,

I have a modification to make r.mapcalc (from QGIS/GRASS 7 processing toolbox) work with windows 7 and QGIS Master (2.99...)

In the file : https://github.com/qgis/QGIS/blob/master/python/plugins/processing/algs/grass7/Grass7Algorithm.py

You should replace in "def exportRasterLayersIntoDirectory" :

for cmd in [self.commands, self.outputCommands]:
    # TODO Windows support
    # TODO Format/options support
cmd.append("for r in $(g.list type=rast pattern='{}*'); do".format(basename))
cmd.append(" r.out.gdal -m{0} input=${{r}} output={1}/${{r}}.tif {2}".format(
' -t' if colorTable else '', outDir,
'--overwrite -c createopt="TFW=YES,COMPRESS=LZW"'
)
)
cmd.append("done")

By this:

for cmd in [self.commands, self.outputCommands]:
    # TODO Windows support
    # TODO Format/options support
cmd.append("for /f %r in ('\"g.list type=rast\"'); do r.out.gdal -m{0} input=%r output={1}/%%r.tif {2}".format(
' -t' if colorTable else '', outDir,
'--overwrite -c createopt=\"TFW=YES,COMPRESS=LZW\"'
)
)

My modification gives this :

Modification in the file

using_01_r_mapcalc.jpg - Sample of using r.mapcalc (142 KB) Olivier ATHIMON, 2018-02-21 03:27 PM

using_02_r_mapcalc.jpg - Sample of using r.mapcalc (quick display) (329 KB) Olivier ATHIMON, 2018-02-21 03:27 PM

using_03_r_mapcalc.jpg - Sample of using r.mapcalc (log 1/2) (492 KB) Olivier ATHIMON, 2018-02-21 03:27 PM

using_04_r_mapcalc.jpg - Sample of using r.mapcalc (log 2/2) (465 KB) Olivier ATHIMON, 2018-02-21 03:27 PM

using_05_r_mapcalc_grass_batch_job_cmd.jpg - Sample of using r.mapcalc (image of file .cmd created) (92.5 KB) Olivier ATHIMON, 2018-02-21 03:31 PM

DEM.tif - DEM (to try this expression : f = DEM + 30) (2.42 MB) Olivier ATHIMON, 2018-02-21 03:33 PM

grass_batch_job.cmd - Sample of using r.mapcalc (file.cmd created) (537 Bytes) Olivier ATHIMON, 2018-02-21 03:34 PM

Proposal_for_Grass7Algorithm.jpg - Modification in the file (227 KB) Olivier ATHIMON, 2018-02-21 03:53 PM

Associated revisions

Revision b39e5a09
Added by Jürgen Fischer almost 2 years ago

processing: add windows support to exportRasterLayersIntoDirectory (fixes #20146)

History

#1 Updated by Giovanni Manghi over 2 years ago

  • Pull Request or Patch supplied changed from No to Yes
  • Status changed from Open to Feedback
  • Priority changed from High to Normal

Please file a pull request in the QGIS code repository. Thanks!

#2 Updated by Alexander Bruy over 2 years ago

  • Assignee deleted (Alexander Bruy)

#3 Updated by Olivier ATHIMON over 2 years ago

Giovanni Manghi wrote:

Please file a pull request in the QGIS code repository. Thanks!

I do it :

commit:e5981c9eb41ff87f0827e14afb39361bb6a6fc8e

https://github.com/qgis/QGIS/blob/e5981c9eb41ff87f0827e14afb39361bb6a6fc8e/python/plugins/processing/algs/grass7/Grass7Algorithm.py

#4 Updated by Giovanni Manghi over 2 years ago

Olivier ATHIMON wrote:

Giovanni Manghi wrote:

Please file a pull request in the QGIS code repository. Thanks!

I do it :

commit:e5981c9eb41

https://github.com/qgis/QGIS/blob/e5981c9eb41ff87f0827e14afb39361bb6a6fc8e/python/plugins/processing/algs/grass7/Grass7Algorithm.py

Hi,
I tested the code (on Windows) and it works which is of course very cool (despite the fact that using r.mapcalc is very cumbersome because is needed to manually write the input file names and that the output is not added to the project).

I have anyway 2 questions:

is the code tested on Linux?

where is your PR?
I cannot find it here

https://github.com/qgis/QGIS/commits?author=ilikeqgis

is not among open or closed ones

https://github.com/qgis/QGIS/pulls

#5 Updated by Jürgen Fischer almost 2 years ago

  • Resolution set to fixed/implemented
  • Status changed from Feedback to Closed

"duplicate" of #20146

Also available in: Atom PDF