Skip to content
Permalink
Browse files

r.reclass inline rules also for MS-Windows

  • Loading branch information
Médéric Ribreux
Médéric Ribreux committed Feb 11, 2016
1 parent 43b39ef commit b780d7caf1c7676277d48cef909664cf38fa29ef
Showing with 9 additions and 2 deletions.
  1. +9 −2 python/plugins/processing/algs/grass7/ext/r_reclass.py
@@ -38,13 +38,20 @@ def processCommand(alg):
""" Handle inline rules """
txtRules = alg.getParameterValue(u'txtrules')
if txtRules:
# Creates a temporary txt file
tempRulesName = alg.getTempFilename()

# Inject rules into temporary txt file
with open(tempRulesName, "w") as tempRules:
tempRules.write(txtRules)

raster = alg.getParameterValue(u'input')
output = alg.getOutputFromName(u'output')
alg.exportedLayers[output.value] = output.name + alg.uniqueSufix
if raster:
raster = alg.exportedLayers[raster]
command = u"echo \"{}\" | r.reclass input={} rules=- output={} --overwrite".format(
txtRules, raster, output.name + alg.uniqueSufix)
command = u"r.reclass input={} rules=- output={} --overwrite < {}".format(
raster, output.name + alg.uniqueSufix, tempRulesName)
alg.commands.append(command)
else:
alg.processCommand()

0 comments on commit b780d7c

Please sign in to comment.
You can’t perform that action at this time.