Skip to content

Commit b780d7c

Browse files
author
Médéric Ribreux
committed
r.reclass inline rules also for MS-Windows
1 parent 43b39ef commit b780d7c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

python/plugins/processing/algs/grass7/ext/r_reclass.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,20 @@ def processCommand(alg):
3838
""" Handle inline rules """
3939
txtRules = alg.getParameterValue(u'txtrules')
4040
if txtRules:
41+
# Creates a temporary txt file
42+
tempRulesName = alg.getTempFilename()
43+
44+
# Inject rules into temporary txt file
45+
with open(tempRulesName, "w") as tempRules:
46+
tempRules.write(txtRules)
47+
4148
raster = alg.getParameterValue(u'input')
4249
output = alg.getOutputFromName(u'output')
4350
alg.exportedLayers[output.value] = output.name + alg.uniqueSufix
4451
if raster:
4552
raster = alg.exportedLayers[raster]
46-
command = u"echo \"{}\" | r.reclass input={} rules=- output={} --overwrite".format(
47-
txtRules, raster, output.name + alg.uniqueSufix)
53+
command = u"r.reclass input={} rules=- output={} --overwrite < {}".format(
54+
raster, output.name + alg.uniqueSufix, tempRulesName)
4855
alg.commands.append(command)
4956
else:
5057
alg.processCommand()

0 commit comments

Comments
 (0)